Simple single-color 8x8x8 LED Cube with AVRs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.c 869B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <stdlib.h>
  2. #include <stdint.h>
  3. #include <avr/io.h>
  4. #include <avr/interrupt.h>
  5. #include <util/delay.h>
  6. #include "uart.h"
  7. #include "cube.h"
  8. #ifndef F_CPU
  9. #define F_CPU 16000000L
  10. #endif
  11. void init(void) {
  12. uint8_t ctr = 0;
  13. DDRD = 0xFF; // Mosfets as Output
  14. DDRB = 0xFF;
  15. DDRC = 0xFF; // Latch Enable
  16. DDRA = 0xFF; // Latch Data
  17. uart_init(UART_BAUD_SELECT(19200, 16000000L));
  18. TCCR1A |= (1 << WGM12); // CTC Mode
  19. TCCR1B |= (1 << CS10); // No prescaler
  20. OCR1A = 3968;
  21. TIMSK = (1 << OCIE1A); // Enable Overflow Interrupt
  22. imgBuffer = malloc(8 * sizeof(uint8_t*));
  23. if (imgBuffer == NULL) {
  24. // TO-DO:
  25. // error!
  26. }
  27. for(ctr = 0; ctr < 8; ctr++) {
  28. imgBuffer[ctr] = malloc(8 * sizeof(uint8_t));
  29. if (imgBuffer[ctr] == NULL) {
  30. // TO-DO:
  31. // error!
  32. }
  33. }
  34. sei(); // Enable Interrupts
  35. }
  36. int main(void) {
  37. init();
  38. while (1) {
  39. }
  40. return 0;
  41. }