I realized a simple example to use Serial Driver, in which I write a char by keyboard and read it on the terminal; I use a thread. Below the code:
Code: Select all
static SerialConfig uartCfg = { BAUDRATE, 0, 0, 0 };
static msg_t SerThd(void *arg) {
(void)arg;
chRegSetThreadName("Read-Write SERIAL-DATA");
// Activates the Serial driver 2, PA2(TX) and PA3(RX) are routed to USART2, 9600 8N1.
palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7));
palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7));
sdStart(&SD2, &uartCfg); // starts the serial driver with uartCfg as a config
uint8_t buffer;
while(TRUE) {
buffer = sdGet(&SD2);
if(strlen(buffer)>0){
sdWrite(&SD2, (uint8_t *)stringBR, strlen(stringBR)); // in defines session there is: stringBR="\r\n";
sdPut(&SD2, buffer);
}
}
return 0;
}
there is a problem with some chars.. when I write them, i don't see:
z, r, f, v, b, n, j, . ,2 and 6 (for letters, both upper and lower case).
Someone can explain me why? Thanks.