i write this code
Code: Select all
#define EVT_UART_RX EVENT_MASK(0)
#define EVT_UART_TX EVENT_MASK(1)
#define EVT_UART_ERR EVENT_MASK(2)
/*
* Pointer to the UART handler thread.
*/
static const uint8_t errore[]="Error uart";
static const uint8_t dati[]="Dati uart";
static const uint8_t letti[]="Read uart";
static const uint8_t hello[]="Hello World";
thread_t *uart_thread;
/*
* Red LED blinker thread, times are in milliseconds.
*/
CH_IRQ_HANDLER(UART_RX_IRQ) {
eventmask_t events = 0;
uint32_t sr;
USART_TypeDef *u=USART2;
sr = u->SR;
u->SR = ~sr;
CH_IRQ_PROLOGUE();
/* Events mask initially at zero.*/
events = 0;
/* If there are errors.*/
if ((u->SR & USART_SR_ORE) != 0)
events |= EVT_UART_ERR;
/* If there is data available in the UART RX FIFO.*/
events |= EVT_UART_ERR;
/* If there is data available in the UART RX FIFO.*/
if ((u->SR & (USART_SR_RXNE | USART_SR_ORE | USART_SR_NE | USART_SR_FE |
USART_SR_PE)) != 0)
if ((u->SR & USART_SR_TXE) != 0) {
events |= EVT_UART_TX;
/* Segnaling events to the thread, if any.*/
if (events) {
chSysLockFromISR();
chEvtSignalI(uart_thread, events);
chSysUnlockFromISR();
}
CH_IRQ_EPILOGUE();
}
}
static THD_WORKING_AREA(waRead1, 128);
static THD_FUNCTION(Thread1,arg) {
(void)arg;
chRegSetThreadName("buffer");
/* Thread activity.*/
while (true) {
/* Waiting for any event.*/
eventmask_t evt = chEvtWaitAny(ALL_EVENTS);
/* Serving events.*/
if (evt & EVT_UART_ERR) {
/* Error event.*/
error_handler();
}
if (evt & EVT_UART_RX) {
/* Data available event.*/
rx_handler();
}
if (evt & EVT_UART_TX) {
/* TX ready event.*/
tx_handler();
}
}
}
void error_handler(){
sdWrite(&SD2, errore, 13);
}
void rx_handler(){
sdWrite(&SD2, dati, 13);
}
void tx_handler(){
sdWrite(&SD2, letti, 13);
}
when i sand data on SD2 i don't see nothing, i dont' know where is the error
can you help me?
best regards
A.