Simple single-color 8x8x8 LED Cube with AVRs
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

audio.c 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * audio.c
  3. *
  4. * Copyright 2012 Thomas Buck <xythobuz@me.com>
  5. *
  6. * This file is part of LED-Cube.
  7. *
  8. * LED-Cube is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * LED-Cube is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with LED-Cube. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include <avr/io.h>
  22. #include <stdint.h>
  23. #include <stdlib.h>
  24. #include "twi.h"
  25. #include "audio.h"
  26. uint8_t ret[7]; // Buffer for data
  27. // don't free returned memory! It's static mem
  28. uint8_t *getAudioData(void) {
  29. // We read 7 bytes from our Audio µC
  30. uint8_t i;
  31. if (i2c_start(TWIADDRESSAUDIO | I2C_READ) == 0) {
  32. for (i = 0; i < 6; i++) {
  33. ret[i] = i2c_readAck();
  34. }
  35. ret[6] = i2c_readNak();
  36. i2c_stop();
  37. return ret;
  38. } else {
  39. return NULL;
  40. }
  41. }