mikroC
mikroC - C Compiler for Microchip PIC microcontrollers
making it simple...
Prototype | void RS485Slave_Receive(char *data); |
|
|
Description | Receives message addressed to it. Messages are |
| called for each byte received (see the example at the end of the chapter). Upon receiving |
| a message, buffer is filled with the following values: |
| data[0..2] is the message, |
| data[3] is number of message bytes received, |
| data[4] is set to 255 when message is received, |
| data[5] is set to 255 if error has occurred, |
| data[6] is the address of the Slave which sent the message. |
| Function automatically adjusts data[4] and data[5] upon every received message. |
| These flags need to be cleared from the program. |
|
|
Requires | MCU must be initialized as Slave in |
| address. See RS485Slave_Init. |
|
|
Example | unsigned short msg[8]; |
| ... |
| RS485Slave_Read(msg); |
|
|
|
| Prototype | void RS485Slave_Send(char *data, char datalen); |
| |
|
|
|
|
| |
|
| Description | Sends data from buffer to Master via |
|
|
|
|
| sage (1 <= datalen <= 3). |
| |
|
|
|
|
| |
|
| Requires | MCU must be initialized as Slave in |
|
|
|
|
| address. See RS485Slave_Init. |
| |
|
|
| It is programmer’s responsibility to ensure (by protocol) that only one device sends data |
| |
|
|
| via 485 bus at a time. |
| |
|
|
|
|
| |
|
| Example | unsigned short msg[8]; |
|
|
|
|
| ... |
|
|
|
|
| RS485Slave_Send(msg, 2); |
| |
|
|
|
|
|
|
|
| page |
|
|
|
|
|
|
| ||
246 | MikroElektronika: Development tools - Books - Compilers | ||||
|
|
|