1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
-
- #include <avr/io.h>
- #include <stdint.h>
- #include <stdlib.h>
-
- #include "twi.h"
- #include "audio.h"
- #ifdef DEBUG
- #include "serial.h"
- #endif
-
-
- uint8_t *getAudioData(void) {
-
- uint8_t i;
- uint8_t *ret = (uint8_t *)malloc(7);
- if (ret == NULL) {
-
- #ifdef DEBUG
- serialWriteString("getAudioData: No memory!\n");
- #endif
- return NULL;
- }
- if (i2c_start(TWIADDRESSAUDIO | I2C_READ) == 0) {
- for (i = 0; i < 6; i++) {
- ret[i] = i2c_readAck();
- }
- ret[6] = i2c_readNak();
- i2c_stop();
- return ret;
- } else {
- free(ret);
- return NULL;
- }
- }
|