123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- typedef enum {
- I2S_UNINIT = 0,
- I2S_STOP = 1,
- I2S_READY = 2,
- I2S_ACTIVE = 3,
- I2S_COMPLETE = 4
- } i2sstate_t;
- typedef struct hal_i2s_driver I2SDriver;
- typedef struct hal_i2s_config I2SConfig;
- typedef void (*i2scallback_t)(I2SDriver *i2sp);
- struct hal_i2s_driver {
-
- i2sstate_t state;
-
- const I2SConfig *config;
-
- i2s_lld_driver_fields;
- };
- struct hal_i2s_config {
-
- const void *tx_buffer;
-
- void *rx_buffer;
-
- size_t size;
-
- i2scallback_t end_cb;
-
- i2s_lld_config_fields;
- };
- i2s_lld_start_exchange(i2sp); \
- (i2sp)->state = I2S_ACTIVE; \
- }
- i2s_lld_stop_exchange(i2sp); \
- (i2sp)->state = I2S_READY; \
- }
- if ((i2sp)->config->end_cb != NULL) { \
- (i2sp)->config->end_cb(i2sp); \
- } \
- }
- if ((i2sp)->config->end_cb) { \
- (i2sp)->state = I2S_COMPLETE; \
- (i2sp)->config->end_cb(i2sp); \
- if ((i2sp)->state == I2S_COMPLETE) { \
- (i2sp)->state = I2S_ACTIVE; \
- } \
- } \
- }
- extern "C" {
- void i2sInit(void);
- void i2sObjectInit(I2SDriver *i2sp);
- void i2sStart(I2SDriver *i2sp, const I2SConfig *config);
- void i2sStop(I2SDriver *i2sp);
- void i2sStartExchange(I2SDriver *i2sp);
- void i2sStopExchange(I2SDriver *i2sp);
- }
|