First Publish. Works fine.
Dependents: unzen_sample_lpcxpresso_4337_callbacks
unzen_hal.h@1:9710fb328a08, 2016-04-12 (annotated)
- Committer:
- shorie
- Date:
- Tue Apr 12 05:51:45 2016 +0000
- Revision:
- 1:9710fb328a08
- Parent:
- 0:5ac19c994288
- Child:
- 2:6613e62da521
added umb-adau1361 support
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shorie | 0:5ac19c994288 | 1 | #ifndef _UNZEN_HAL_H_ |
shorie | 0:5ac19c994288 | 2 | #define _UNZEN_HAL_H_ |
shorie | 0:5ac19c994288 | 3 | |
shorie | 0:5ac19c994288 | 4 | #include "mbed.h" |
shorie | 0:5ac19c994288 | 5 | |
shorie | 0:5ac19c994288 | 6 | namespace unzen |
shorie | 0:5ac19c994288 | 7 | { |
shorie | 0:5ac19c994288 | 8 | // Set up I2S peripheral to ready to start. |
shorie | 0:5ac19c994288 | 9 | // By this HAL, the I2S have to become : |
shorie | 0:5ac19c994288 | 10 | // - slave mode |
shorie | 0:5ac19c994288 | 11 | // - clock must be ready |
shorie | 0:5ac19c994288 | 12 | // - Interrupt enable. |
shorie | 0:5ac19c994288 | 13 | void hal_i2s_setup(); |
shorie | 0:5ac19c994288 | 14 | |
shorie | 1:9710fb328a08 | 15 | // configure the pins of I2S and then, wait for WS. |
shorie | 1:9710fb328a08 | 16 | // This waiting is important to avoid the delay between TX and RX. |
shorie | 1:9710fb328a08 | 17 | // The HAL API will wait for the WS changes from left to right then return. |
shorie | 1:9710fb328a08 | 18 | // The procesure is : |
shorie | 1:9710fb328a08 | 19 | // 1. configure all pin as GPIO |
shorie | 1:9710fb328a08 | 20 | // 2. wait the WS |
shorie | 1:9710fb328a08 | 21 | // 3. configure all pin as I2S |
shorie | 1:9710fb328a08 | 22 | void hal_i2s_pin_config_and_wait_ws(); |
shorie | 1:9710fb328a08 | 23 | |
shorie | 1:9710fb328a08 | 24 | |
shorie | 0:5ac19c994288 | 25 | // Start I2S transfer. Interrupt starts |
shorie | 0:5ac19c994288 | 26 | void hal_i2s_start(); |
shorie | 0:5ac19c994288 | 27 | |
shorie | 0:5ac19c994288 | 28 | IRQn_Type hal_get_i2s_irq_id(); |
shorie | 0:5ac19c994288 | 29 | IRQn_Type hal_get_process_irq_id(); |
shorie | 0:5ac19c994288 | 30 | |
shorie | 0:5ac19c994288 | 31 | // The returned value must be compatible with CMSIS NVIC_SetPriority() API. |
shorie | 0:5ac19c994288 | 32 | unsigned int hal_get_lowest_priority_level(); |
shorie | 0:5ac19c994288 | 33 | |
shorie | 0:5ac19c994288 | 34 | // reutun the intenger value which tells how much data have to be transfered for each |
shorie | 0:5ac19c994288 | 35 | // interrupt. For example, if the stereo 32bit data ( total 64 bit ) have to be sent, |
shorie | 0:5ac19c994288 | 36 | // have to return 2. |
shorie | 0:5ac19c994288 | 37 | // The special case is when the word needs to transmit by multiple interrupt, |
shorie | 0:5ac19c994288 | 38 | // must return 0. |
shorie | 0:5ac19c994288 | 39 | unsigned int hal_data_per_sample(); |
shorie | 0:5ac19c994288 | 40 | |
shorie | 0:5ac19c994288 | 41 | // return true when the sample parameter is ready to read. |
shorie | 0:5ac19c994288 | 42 | // return false when the sample is not ready to read. |
shorie | 0:5ac19c994288 | 43 | bool hal_get_i2s_rx_data( int & sample); |
shorie | 0:5ac19c994288 | 44 | |
shorie | 0:5ac19c994288 | 45 | // return true when the sample was completely stored to send. |
shorie | 0:5ac19c994288 | 46 | // return false when the same sample is required next time. |
shorie | 0:5ac19c994288 | 47 | bool hal_set_i2s_tx_data( int sample ); |
shorie | 0:5ac19c994288 | 48 | } |
shorie | 0:5ac19c994288 | 49 | |
shorie | 0:5ac19c994288 | 50 | |
shorie | 0:5ac19c994288 | 51 | #endif |