34 #ifdef __BUILD_WITH_EXAMPLE__
35 #include "lpc17xx_libcfg.h"
56 static uint8_t i2s_GetWordWidth(
LPC_I2S_TypeDef *I2Sx, uint8_t TRMode) {
63 value = (I2Sx->
I2SDAO) & 0x03;
65 value = (I2Sx->
I2SDAI) & 0x03;
92 value = (I2Sx->
I2SDAO) & 0x04;
94 value = (I2Sx->
I2SDAI) & 0x04;
137 uint32_t bps, config;
152 config = (bps - 1)<<6 | (ConfigStruct->
ws_sel)<<5 | (ConfigStruct->
reset)<<4 |
189 return ((I2Sx->
I2SSTATE >> 16) & 0xFF);
193 return ((I2Sx->
I2SSTATE >> 8) & 0xFF);
322 uint8_t bitrate, channel, wordwidth;
326 uint8_t x_divide = 0, y_divide = 0;
327 uint16_t ErrorOptimal = 0xFFFF;
344 bitrate = channel * wordwidth - 1;
365 divider = ((uint64_t)(Freq *( bitrate+1)* 2)<<16) / i2sPclk;
366 for (y = 255; y > 0; y--) {
369 if(dif>0x8000) error = 0x10000-dif;
376 else if (error < ErrorOptimal)
378 ErrorOptimal = error;
382 x_divide = (y_divide * Freq *( bitrate+1)* 2)/i2sPclk;
385 I2Sx->
I2STXRATE = y_divide | (x_divide << 8);
388 I2Sx->
I2SRXRATE = y_divide | (x_divide << 8);
560 I2Sx->
I2SIRQ |= (level << 8);
562 I2Sx->
I2SIRQ |= (level << 16);
610 return ((I2Sx->
I2SIRQ >> 1)&0x01);
612 return ((I2Sx->
I2SIRQ)&0x01);
627 return (((I2Sx->
I2SIRQ)>>16)&0xFF);
629 return (((I2Sx->
I2SIRQ)>>8)&0xFF);