Serial Wombat 4A and 4B Firmware
|
Macros | |
#define | I2C_REINIT_TIME 30000 |
Functions | |
void | ProcessSetPin () |
Processes a pin mode configuration packet. More... | |
void | UART1_WriteBuffer (uint8_t *buffer, uint8_t count) |
void | WriteCRLF () |
Send a carraige return / line feed to the host. More... | |
void | uartStartTX () |
Send the Txbuffer to the host. More... | |
void | ProcessRx (void) |
void | protocol_1ms () |
Called every 1 mS to timeout I2C clock stretching. More... | |
Variables | |
uint8_t | UartRxbufferCounter = 0 |
The number of bytes received towards a new packet. More... | |
uint8_t | Rxbuffer [RXBUFFER_LENGTH] |
A buffer for incoming commands from the host. More... | |
uint8_t | Txbuffer [TXBUFFER_LENGTH] |
A buffer for outgoing commands to the host. More... | |
uint16_t | I2C_Reinit_Countdown = I2C_REINIT_TIME |
__bit | I2C_Recovery |
volatile uint8_t | i2cTxBufferCounter |
When using I2C, the number of bytes remaining to send. More... | |
bool | LineBreaksAndEcho = false |
When true, add line breaks to each command and echo bytes back to the host. Used for manual command entry over terminal. More... | |
uint8_t | i2c_sda_low_counter = 0 |
This file contains the functions which process incoming data from the host and generate response packets.
#define I2C_REINIT_TIME 30000 |
void ProcessRx | ( | void | ) |
void ProcessSetPin | ( | ) |
Processes a pin mode configuration packet.
This subroutine processes all Pin Configuration requests based on 8 bytes stored in Rxbuffer. Pins set in Digital I/O pin mode are handled directly in this function. Other pin modes are handled by initailization functions that exist in the .c file that defines that pin mode.
BYTE 0 | BYTE 1 | BYTE 2 | BYTE 3 | BYTE 4 | BYTE 5 | BYTE 6 | BYTE 7 |
---|---|---|---|---|---|---|---|
0xC0 | Pin To Set | 0x00 (Digital I/O mode) | 0x00, 0x01, or 0x02 (Low, high, input) | 0x00 or 0x01 (Weak Pull up off, Weak Pull up on) | 0x00 (reserved for chips that support weak pull downs) | 0x00 or 0x01 (Open Drain mode off or on) | 0x55* |
0x55 is recommended, but any byte is acceptable
Response:
Command is echoed back.
Examples:
Set pin 2 to Digital I/O, High, no weak pull up, normal mode
0xC0 0x02 0x00 0x01 0x00 0x00 0x00 0x55
Set pin 3 to Digital I/O, Input, wth weak pull up, normal mode
0xC0 0x03 0x00 0x02 0x01 0x00 0x00 0x55
Set pin 1 to Digital I/O, low, open drain
0xC0 0x01 0x00 0x00 0x00 0x00 0x01 0x55
void protocol_1ms | ( | ) |
Called every 1 mS to timeout I2C clock stretching.
Leaving the Clock stretching bit set indefinitely will lock up the I2C bus preventing any device from using it. We should never be stuck for more than 1 mS. This function monitors clock stretching time and forces a reset of the I2C bus if a timeout occurs, releasing the I2C bus.
void UART1_WriteBuffer | ( | uint8_t * | buffer, |
uint8_t | count | ||
) |
void uartStartTX | ( | ) |
Send the Txbuffer to the host.
void WriteCRLF | ( | ) |
Send a carraige return / line feed to the host.
__bit I2C_Recovery |
uint16_t I2C_Reinit_Countdown = I2C_REINIT_TIME |
uint8_t i2c_sda_low_counter = 0 |
volatile uint8_t i2cTxBufferCounter |
When using I2C, the number of bytes remaining to send.
bool LineBreaksAndEcho = false |
When true, add line breaks to each command and echo bytes back to the host. Used for manual command entry over terminal.
uint8_t Rxbuffer[RXBUFFER_LENGTH] |
A buffer for incoming commands from the host.
uint8_t Txbuffer[TXBUFFER_LENGTH] |
A buffer for outgoing commands to the host.
uint8_t UartRxbufferCounter = 0 |
The number of bytes received towards a new packet.