[tuxdroid-svn] r1260 - firmware/tuxaudio/branches/new_rf
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2008-06-24 12:16:19
|
Author: jaguarondi Date: 2008-06-24 14:16:28 +0200 (Tue, 24 Jun 2008) New Revision: 1260 Modified: firmware/tuxaudio/branches/new_rf/communication.c firmware/tuxaudio/branches/new_rf/i2c.c firmware/tuxaudio/branches/new_rf/i2c.h Log: * Changed the I2C service routine to speed-it up. Parsing is now done outside the interrupt. Modified: firmware/tuxaudio/branches/new_rf/communication.c =================================================================== --- firmware/tuxaudio/branches/new_rf/communication.c 2008-06-24 12:07:58 UTC (rev 1259) +++ firmware/tuxaudio/branches/new_rf/communication.c 2008-06-24 12:16:28 UTC (rev 1260) @@ -36,6 +36,8 @@ /* I2C read message (in) */ static uint8_t in_buf[CMD_SIZE]; static struct i2c_msg msg_in = {0, 0, in_buf}; +/* I2C last received command */ +static uint8_t *received_cmd = 0; /** Size of the stack buffer to tuxcore */ #define CORE_OUT_BUF_SIZE 16 @@ -182,28 +184,21 @@ * \param msg I2C message received * \return 0 if a stop should be sent, 1 for a restart. */ -bool i2c_master_receive_service(struct i2c_msg *msg) +void i2c_master_receive_service(struct i2c_msg *msg) { if (msg->len != CMD_SIZE) /* Error here. */ - return 0; + return; if (*(msg->buf) == 0) { /* Got nothing so stop reading. */ - return 0; + return; } if (msg->addr == TUXCORE_ADDR) /* From tuxcore */ { - /* Parse the command and forward if it isn't dropped. */ - if (!parse_cmd(msg->buf)) - queue_rf_cmd(msg->buf); - /* As we got something, there's maybe more so if the stack is not full, - * continue */ - if (FifoLength(rf_cmdout_buf) <= RF_BUF_SIZE - CMD_SIZE) - return 1; + received_cmd = msg->buf; } - return 0; } /* @@ -448,9 +443,17 @@ return; } + /* Parse the received command and forward if it isn't dropped. */ + if (received_cmd) + { + if (!parse_cmd(received_cmd)) + queue_rf_cmd(received_cmd); + received_cmd = 0; + } + /* Send otherwise get commands. */ - //if (!send_core_cmds()) - //{ - //get_core_cmd(); - //} + if (!send_core_cmds()) + { + get_core_cmd(); + } } Modified: firmware/tuxaudio/branches/new_rf/i2c.c =================================================================== --- firmware/tuxaudio/branches/new_rf/i2c.c 2008-06-24 12:07:58 UTC (rev 1259) +++ firmware/tuxaudio/branches/new_rf/i2c.c 2008-06-24 12:16:28 UTC (rev 1260) @@ -84,7 +84,7 @@ /* function pointer to i2c receive routine */ /* I2cSlaveReceive is called when this processor is addressed as a slave for * writing */ -static bool (*i2c_master_receive) (struct i2c_msg *msg); +static void (*i2c_master_receive) (struct i2c_msg *msg); /* I2cSlaveTransmit is called when this processor is addressed as a slave for * reading */ static uint8_t(*i2cSlaveTransmit) (uint8_t transmitDataLengthMax, @@ -99,7 +99,7 @@ //i2c_resume(); /* Set the user function which handles receiving (incoming) data as a slave */ -void i2c_master_receive_handler(bool (*i2cMasterRx_func) (struct i2c_msg *msg)) +void i2c_master_receive_handler(void (*i2cMasterRx_func) (struct i2c_msg *msg)) { i2c_master_receive = i2cMasterRx_func; } @@ -362,14 +362,8 @@ m_msg->state = i2c_state; if (i2c_master_receive) { - if (i2c_master_receive(m_msg)) - { - buf_idx = 0; - i2c_state = I2C_BUSY; - twi_send_start(); /* restart a read */ - } - else - twi_send_stop(); /* end of data stream */ + i2c_master_receive(m_msg); + twi_send_stop(); /* end of data stream */ } break; case TW_MT_SLA_NACK: /* 0x20 */ Modified: firmware/tuxaudio/branches/new_rf/i2c.h =================================================================== --- firmware/tuxaudio/branches/new_rf/i2c.h 2008-06-24 12:07:58 UTC (rev 1259) +++ firmware/tuxaudio/branches/new_rf/i2c.h 2008-06-24 12:16:28 UTC (rev 1260) @@ -80,7 +80,7 @@ /* Functions */ void i2cInit(void); -void i2c_master_receive_handler(bool (*i2cMasterRx_func) (struct i2c_msg *msg)); +void i2c_master_receive_handler(void (*i2cMasterRx_func) (struct i2c_msg *msg)); void i2cSetSlaveTransmitHandler(uint8_t(*i2cSlaveTx_func) (uint8_t transmitDataLengthMax, |