File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed
examples/I2SDMA_RXCallBack Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change 25
25
#include " wiring_constants.h"
26
26
#include " wiring_digital.h"
27
27
28
+ #define SETTLING_TIME 400
29
+
28
30
extern void UART_Handler (void );
29
31
extern void serialEventRun (void ) __attribute__((weak));
30
32
extern void serialEvent (void ) __attribute__((weak));
@@ -115,6 +117,7 @@ void UARTClass::end( void )
115
117
116
118
SET_PIN_MODE (17 , GPIO_MUX_MODE); // Rdx SOC PIN (Arduino header pin 0)
117
119
SET_PIN_MODE (16 , GPIO_MUX_MODE); // Txd SOC PIN (Arduino header pin 1)
120
+ delayMicroseconds (SETTLING_TIME); // wait for lines to settle
118
121
}
119
122
120
123
void UARTClass::setInterruptPriority (uint32_t priority)
Original file line number Diff line number Diff line change 20
20
21
21
#define BUFF_SIZE 128
22
22
#define OFFSET 2
23
- uint32_t dataBuff[BUFF_SIZE+OFFSET]; // extra 2 buffer is for the padding zero
23
+ uint32_t dataBuff[BUFF_SIZE+OFFSET]; // extra 2 buffers are for the padding zero
24
24
25
+ /* *
26
+ * the received data: the higher 16 bits should be equal to loop_count and the lower 16 bits should be (0x01~0x80)
27
+ * loop_count should increase by 1 in evry loop()
28
+ * for example: if first time the received data is 0x00010001~0x00010080, then next time the data should be 0x00020001~0x00020080
29
+ **/
25
30
uint8_t start_flag = 0 ;
26
- uint8_t done_flag = 0 ;
27
- uint32_t loop_count = 0 ;
28
- uint32_t shift_count = 0 ;
31
+ uint8_t done_flag = 0 ; // when done_flag is 1, the received data are correct
32
+ uint32_t loop_count = 0 ; // record the higher 16 bits of received data
33
+ uint32_t shift_count = 0 ; // the position of first non-zero
29
34
void setup ()
30
35
{
31
36
Serial.begin (115200 );
@@ -61,7 +66,8 @@ void loop()
61
66
}
62
67
if (shift_count > OFFSET)
63
68
return ;
64
-
69
+
70
+ // record the higher 16 bits of received data
65
71
if (start_flag)
66
72
{
67
73
if ((dataBuff[shift_count]>>16 ) != loop_count+1 )
@@ -73,7 +79,7 @@ void loop()
73
79
}
74
80
loop_count = (dataBuff[shift_count] >> 16 );
75
81
76
- // check data
82
+ // check data serial: the higher 16 bits should be equal to loop_count and the lower 16 bits should be (0x01~0x80)
77
83
done_flag = 1 ;
78
84
for (uint32_t i = 0 ;i < BUFF_SIZE;++i)
79
85
{
Original file line number Diff line number Diff line change 20
20
21
21
// CurieI2SDMA.h
22
22
23
- #ifndef _CURI2SDMA_H_
24
- #define _CURI2SDMA_H_
23
+ #ifndef _CURIEI2SDMA_H_
24
+ #define _CURIEI2SDMA_H_
25
25
26
26
#include < Arduino.h>
27
27
You can’t perform that action at this time.
0 commit comments