30 uint8_t replyBuf[512];
46 if (count > MAX_READS) {
56 for (i = 0; i < count; ++i, ++addr)
77 if (count > MAX_READS) {
82 for (i = 0; i < count; ++i, ++addr)
108 if (count > MAX_READS) {
116 for (i = 0; i < count; ++i, ++addr)
120 *addr = ( *addr & ~mask ) | ( value & mask);
131 #define MAX_I2C_DATE_LEN 32
142 uint8_t i2cBuf[MAX_I2C_DATE_LEN];
146 if (iface > 2)
return false;
154 if (len > MAX_I2C_DATE_LEN)
return false;
156 if (!
i2cRead(_i2cDevs[iface], addr, i2cBuf, len))
167 for (i = 0; i < len; ++i)
178 if (
dbLength(buf) < 6 )
return false;
185 uint8_t i2cBuf[MAX_I2C_DATE_LEN];
189 if (iface > 2)
return false;
195 if (len > MAX_I2C_DATE_LEN)
return false;
197 for (i = 0; i < len; ++i)
202 if (!
i2cWrite(_i2cDevs[iface], addr, i2cBuf, len))
221 return UART_DESCR_PTR(UART_ID1);
224 return UART_DESCR_PTR(UART_ID2);
226 return UART_DESCR_PTR(UART_ID3);
228 return UART_DESCR_PTR(UART_ID4);
236 #define UART_BUFFER_SIZE 80
239 #define FLASH_READ_SIZE 256
240 #define FLASH_READ_MASK (FLASH_READ_SIZE - 1)
249 if ((addr & FLASH_READ_MASK) != 0)
253 sfRead(addr, reply.
cur, FLASH_READ_SIZE);
254 reply.
cur+=FLASH_READ_SIZE;
262 char tmp[UART_BUFFER_SIZE];
268 if (u == NULL)
return false;
273 while (*ptr !=
'\0') {
287 uint8_t uartBuf[UART_BUFFER_SIZE + 2];
288 char tmp[UART_BUFFER_SIZE];
292 if (u == NULL)
return false;
bool i2cWrite(I2C_Device *dev, i2cAddr addr, uint8_t *bytes, int len)
Writes to the I2C device.
bool _msgBusRead(MsgId *id, DataBuffer *buf)
Reads an address.
bool dbReadU8(DataBuffer *buf, uint8_t *byte)
Reads an unsigned byte.
bool dbReadString(DataBuffer *buf, char *s, int size)
Reads a string from the stream.
bool dbReadU16(DataBuffer *buf, uint16_t *u)
Reads a unsigned short (16 bits unsigned) integer.
Structure defines OpenCores I2C Device.
static bool suartTxReady(SUART_Descriptor *desc)
Returns whether or not the TX buffer is empty.
White Rabbit Simple UART Driver.
PacketLog_t * getPacketLog(uint32_t pos)
Get packet log at position pos.
const char * errGetDescr()
Returns the last error description, if any, else null.
bool _msgBusWrite(MsgId *id, DataBuffer *buf)
Writes one or more addresses.
#define I2C3
Virtual OpenCores I2C.
#define I2C2
Virtual OpenCores I2C.
Defines a DataBuffer structure.
#define E_INVARGUMENT
Generic error: invalid argument.
static uint32_t dbLength(DataBuffer *buf)
Returns the lenght of the current buffer.
Handles MCF packed messages from the higher protocol layer.
bool msgTxReply(MsgId *id, DataBuffer *buf)
Invoke to send a reply.
bool msgTxError(MsgId *id, int errCode, const char *errMsg, const char *name)
Invoke to send an error response.
void resetPacketLog()
Reset the packet log.
void errClear()
Clears the current error.
bool msgRxBufCheck(DataBuffer *buf)
Checks the received buffer, and logs an error if there is something wrong.
uint32_t errGet()
Returns the last error code, or null.
This module is responsible for distributing error codes.
bool suartRx(SUART_Descriptor *desc, char *c)
Receives a character.
bool dbWriteU8(DataBuffer *buf, uint8_t byte)
Writes a unsigned byte.
bool i2cRead(I2C_Device *dev, i2cAddr addr, uint8_t *bytes, int len)
Reads from the I2C device.
#define I2C1
Virtual OpenCores I2C.
bool dbReadU32(DataBuffer *buf, uint32_t *u)
Reads an 32 bits unsigned integer.
bool sfRead(uint32_t address, uint8_t *data, uint32_t count)
Read from a specific address in flash.
If defined, events will not require an acknowledge.
bool dbWriteString(DataBuffer *buf, const char *s, int max)
Writes a String as 'sort of' UTF-8 encoding, as defined in the Java DataOuput and DataInput writeUTF ...
static bool suartRxReady(SUART_Descriptor *desc)
Returns whether or not the RX buffer has data.
This file assigns all device structures to memory mapped structures.
const char * errGetName()
Returns the last error cause name, or null.
#define ERROR(CODE,...)
Expands an error code to an error code with a description (if ERROR_W_DESCR is declared).
This driver implements access to the Serial Flash.
bool dbReadI16(DataBuffer *buf, int16_t *i)
Reads a short (16 bits signed) integer.
bool suartTx(SUART_Descriptor *desc, char c)
Transmits a character.
#define DB_BUF_INIT(PTR, LEN)
Simple buffer initialization.
uint8_t * cur
Current Pointer.
static bool msgTxReplyAck(MsgId *id)
Replies a simple ACK with no content.
bool dbWriteU32(DataBuffer *buf, uint32_t u)
Writes an 32 bits unsigned integer.
bool dbWriteU16(DataBuffer *buf, uint16_t u)
Writes a unsigned short (16 bits unsigned) integer.
OpenCores I2C device driver.