Guest User

Untitled

a guest
Jan 18th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. void DRV_I2S_BaudSet(DRV_HANDLE handle, uint32_t spiClock, uint32_t baud)
  2.  
  3. /* Clock System Service Configuration Options*/
  4. #define SYS_CLK_FREQ 200000000ul
  5. #define SYS_CLK_BUS_PERIPHERAL_1 100000000ul
  6. #define SYS_CLK_BUS_PERIPHERAL_2 100000000ul
  7. #define SYS_CLK_BUS_PERIPHERAL_3 100000000ul
  8. #define SYS_CLK_BUS_PERIPHERAL_4 100000000ul
  9. #define SYS_CLK_BUS_PERIPHERAL_5 100000000ul
  10. #define SYS_CLK_BUS_PERIPHERAL_7 200000000ul
  11. #define SYS_CLK_BUS_PERIPHERAL_8 100000000ul
  12. #define SYS_CLK_BUS_REFERENCE_1 4096000ul
  13. #define SYS_CLK_CONFIG_PRIMARY_XTAL 24000000ul
  14. #define SYS_CLK_CONFIG_SECONDARY_XTAL 32768ul
  15.  
  16. spiClock = SYS_CLK_BUS_REFERENCE_1;
  17.  
  18. switch(appVoiceRecordLoopData.state)
  19. {
  20. case APP_VOICE_RECORD_LOOP_STATES_CODEC_OPEN:
  21. {
  22. /* A client opens the driver object to get an Handle */
  23. appVoiceRecordLoopData.codecClient.handle = DRV_I2S_Open(DRV_I2S_INDEX_0,
  24. DRV_IO_INTENT_READ | DRV_IO_INTENT_EXCLUSIVE);
  25. if(appVoiceRecordLoopData.codecClient.handle != DRV_HANDLE_INVALID)
  26. {
  27. // Sets the baud rate to a new value as below
  28. //The baud to be set.
  29. baud = 64000; <======Need to change this!!!
  30. clock = 4096000ul;
  31. DRV_I2S_BaudSet(appVoiceRecordLoopData.codecClient.handle, clock, baud);
  32. appVoiceRecordLoopData.state = APP_VOICE_RECORD_LOOP_STATES_CODEC_SET_BUFFER_HANDLER;
  33. }
  34. else
  35. {
  36. /* Got an Invalid Handle. Wait for CODEC to Initialize */
  37. ;
  38. }
  39. }
  40. break;
  41.  
  42. /* Set a handler for the audio buffer completion event */
  43. case APP_VOICE_RECORD_LOOP_STATES_CODEC_SET_BUFFER_HANDLER:
  44. {
  45.  
  46. DRV_I2S_BufferEventHandlerSet(appVoiceRecordLoopData.codecClient.handle,
  47. appVoiceRecordLoopData.codecClient.bufferEventHandler,
  48. appVoiceRecordLoopData.codecClient.context);
  49.  
  50. appVoiceRecordLoopData.state = APP_VOICE_RECORD_LOOP_STATES_CODEC_ADD_FIRST_BUFFER_READ;
  51. }
  52. break;
  53.  
  54. case APP_VOICE_RECORD_LOOP_STATES_CODEC_ADD_FIRST_BUFFER_READ:
  55. {
  56. /* Initiate the first Read Request */
  57. DRV_I2S_BufferAddRead(appVoiceRecordLoopData.codecClient.handle,
  58. &appVoiceRecordLoopData.codecClient.writeReadBufHandle,
  59. appVoiceRecordLoopData.codecClient.rxbufferObject,
  60. appVoiceRecordLoopData.codecClient.bufferSize);
  61.  
  62. if(DRV_I2S_BUFFER_HANDLE_INVALID != appVoiceRecordLoopData.codecClient.writeReadBufHandle)
  63. {
  64. appVoiceRecordLoopData.state = APP_VOICE_RECORD_LOOP_STATES_CODEC_WAIT_FOR_BUFFER_COMPLETE;
  65. }
  66. }
  67. break;
  68.  
  69. /* Audio data request under process */
  70. case APP_VOICE_RECORD_LOOP_STATES_CODEC_WAIT_FOR_BUFFER_COMPLETE:
  71. {
  72. ; /*Do nothing*/
  73. }
  74. break;
Add Comment
Please, Sign In to add comment