2012-11-20 02:34 PM
Hello,
I looking for some example code for communication between my ST-DISCOVERY F0 board and PC (UART). Can someone help me with it? I´m novice.Thank you2015-05-07 11:03 AM
Well it means you've got it specified twice, right?
Put the typedef and prototype definitions in the .H fileInclude the .H file once in each .C fileDon't define the typedef in the .C file, just the body code for the functions you have prototyped.2015-05-07 01:42 PM
Now, I have three .c files (main.c, fifo.c, stdio_through_usart.c). In all of them is included fifo.h.
fifo.h contains:#ifndef FIFO_H
#define FIFO_H
#define RXSIZE 1024
#define TXSIZE 512
uint8_t RxBuffer[RXSIZE];
uint8_t TxBuffer[TXSIZE];
typedef
struct
{
char
* buf;
int
head;
int
tail;
int
size;
} fifo_t;
fifo_t RxFifo[1];
fifo_t TxFifo[1];
void
fifo_init(fifo_t * f,
char
* buf,
int
size);
int
fifo_read(fifo_t * f,
void
* buf,
int
nbytes);
int
fifo_write(fifo_t * f,
const
void
* buf,
int
nbytes);
#endif /* FIFO_H */
But now there is new errors. Is this double inclusion? I have defined these arrays just once.
Error: L6200E: Symbol RxBuffer multiply defined (by stdio_through_usart.o and main.o).
Error: L6200E: Symbol RxBuffer multiply defined (by fifo.o and main.o).
Error: L6200E: Symbol TxBuffer multiply defined (by stdio_through_usart.o and main.o).
Error: L6200E: Symbol TxBuffer multiply defined (by fifo.o and main.o).
Error: L6200E: Symbol RxFifo multiply defined (by stdio_through_usart.o and main.o).
Error: L6200E: Symbol RxFifo multiply defined (by fifo.o and main.o).
Error: L6200E: Symbol TxFifo multiply defined (by stdio_through_usart.o and main.o).
Error: L6200E: Symbol TxFifo multiply defined (by fifo.o and main.o).
2015-05-07 04:16 PM
Define the actual variables, once, in your .C file, and the refer to them in your .H file with the extern prefix.
2015-05-07 04:18 PM
2015-05-13 09:43 AM
to be migrated, sourceId: 13890:74F499D6-C293-4561-BFB5-4F1489999957
2015-05-13 11:02 AM
It's a FIFO, you've presumably already pulled other byte(s) from the buffer, and the tail has moved forward to account for that. It doesn't shift/copy the buffer content, it keeps track of where the ''next'' byte should come from.
Variable advances, data doesn't move.2015-05-13 11:09 AM
to be migrated, sourceId: 13895:74F499D6-C293-4561-BFB5-4F1489999957
2015-09-16 07:04 AM
Dear All,
How I can retarget scanf function to software buffer in order to send data in interrupt handler?2015-09-16 08:33 AM
Keil allows you to provide a replacement for int fgetc(FILE *f)
int fgetc(FILE *f)
{
uint16_t ch;
while(USART_GetFlagStatus(USART1, USART_FLAG_RXNE) == RESET);
ch = USART_ReceiveData(USART1);
return((int)ch);
}
Alternatively, make a buffer, and use sscanf() ?
2015-11-26 04:48 AM
Hi clive1,
I am new to STM32F0 contoller. I need to communicate 2 STM32F0 controllers using RS485 protocol.Could you please share the code.Thanks