[tuxdroid-svn] r577 - firmware/fuxusb/trunk
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-10-02 21:19:04
|
Author: jaguarondi Date: 2007-10-02 23:18:59 +0200 (Tue, 02 Oct 2007) New Revision: 577 Modified: firmware/fuxusb/trunk/bootloading.c firmware/fuxusb/trunk/bootloading.h firmware/fuxusb/trunk/config.h firmware/fuxusb/trunk/global.c firmware/fuxusb/trunk/global.h firmware/fuxusb/trunk/i2c.c firmware/fuxusb/trunk/i2c.h firmware/fuxusb/trunk/main.c firmware/fuxusb/trunk/version.h Log: * Cleanup of the USB code, removed extra whitespaces and tabs. Modified: firmware/fuxusb/trunk/bootloading.c =================================================================== --- firmware/fuxusb/trunk/bootloading.c 2007-10-02 21:03:04 UTC (rev 576) +++ firmware/fuxusb/trunk/bootloading.c 2007-10-02 21:18:59 UTC (rev 577) @@ -1,8 +1,7 @@ - /* KySoH iTux agent * * Behavioural source code - * created on 2005/10/19 David Bourgeois + * created on 2005/10/19 David Bourgeois * -------------------------------------------------------- * $Id$ */ @@ -18,15 +17,15 @@ uint8_t address_idx; uint8_t packet_idx; -blHeader_t blHeader; /* header for bootloading */ +blHeader_t blHeader; /* header for bootloading */ /* * Initialize i2c interface */ void blInit(void) { - i2cSetBitrate(); /* set TWI bitrate */ - i2cInit(); /* initialize TWI interface */ + i2cSetBitrate(); /* set TWI bitrate */ + i2cInit(); /* initialize TWI interface */ blHeader.blData = &i2cSendData[2]; } @@ -43,7 +42,7 @@ { i2cFlags.s_val = 0; i2cDeviceAddrRW = blHeader.slave_address; - i2cSendData[0] = blHeader.page_address >> 8; /* the first 2 bytes of the i2c frame are the page address */ + i2cSendData[0] = blHeader.page_address >> 8; /* the first 2 bytes of the i2c frame are the page address */ i2cSendData[1] = blHeader.page_address; i2cSendDataLength = dataLength + 2; i2cMasterStart(); Modified: firmware/fuxusb/trunk/bootloading.h =================================================================== --- firmware/fuxusb/trunk/bootloading.h 2007-10-02 21:03:04 UTC (rev 576) +++ firmware/fuxusb/trunk/bootloading.h 2007-10-02 21:18:59 UTC (rev 577) @@ -14,11 +14,11 @@ #include "config.h" /** USB bootloader commands */ -#define BOOT_INIT 1 +#define BOOT_INIT 1 #define BOOT_FILLPAGE 2 #define BOOT_EXIT 3 -#define BOOTLOADER_CMD (uint8_t)0xF0 /* Bootloader status command */ +#define BOOTLOADER_CMD (uint8_t)0xF0 /* Bootloader status command */ /** * \brief Bootloading header structure which holds all information to initiate Modified: firmware/fuxusb/trunk/config.h =================================================================== --- firmware/fuxusb/trunk/config.h 2007-10-02 21:03:04 UTC (rev 576) +++ firmware/fuxusb/trunk/config.h 2007-10-02 21:18:59 UTC (rev 577) @@ -1,10 +1,10 @@ /*H************************************************************************** -* NAME: config.h +* NAME: config.h *---------------------------------------------------------------------------- * Copyright (c) 2004 Atmel. *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: * Describes the system dependant software configuration. * This file is included by all source files in order to access to system wide * configuration. @@ -35,89 +35,89 @@ //#define BOOTLOAD_DEBUG //#define USB_CMD_DEBUG #define VERBOSE 0 -#define DEBUG_1 P3_6 -#define DEBUG_2 P4_0 +#define DEBUG_1 P3_6 +#define DEBUG_2 P4_0 /*_____ D E F I N I T I O N ________________________________________________*/ // Board config -#define FOSC 24000 -#define CPUB_VERSION //#define FILE_BOARD_H "lib_board/c5131_evab.h" 0x0102 -#define X2_MODE // Allow use of c51 x2 mode feature +#define FOSC 24000 +#define CPUB_VERSION //#define FILE_BOARD_H "lib_board/c5131_evab.h" 0x0102 +#define X2_MODE // Allow use of c51 x2 mode feature #define SPI_Clock_Div8 -#define BAUDRATE 115200 // in bps -#define BDR_GENERATOR BRG_TIMER2 // Available value: BRG_INTERNAL, BRG_TIMER1, BRG_TIMER2 +#define BAUDRATE 115200 // in bps +#define BDR_GENERATOR BRG_TIMER2 // Available value: BRG_INTERNAL, BRG_TIMER1, BRG_TIMER2 /*_____ D E F I N I T I O N ________________________________________________*/ /* USB Configuration */ /* DEVICE DESCRIPTOR */ -#define EP_AUDIO_IN 1 -#define EP_AUDIO_OUT 2 -#define EP_AUDIO_OUT_TTS 3 -#define EP_CMD_IN 4 -#define EP_CMD_OUT 5 +#define EP_AUDIO_IN 1 +#define EP_AUDIO_OUT 2 +#define EP_AUDIO_OUT_TTS 3 +#define EP_CMD_IN 4 +#define EP_CMD_OUT 5 -#define USB_SPECIFICATION 0x1001 -#define DEVICE_CLASS 0x00 -#define DEVICE_SUB_CLASS 0 -#define DEVICE_PROTOCOL 0 -#define EP_CONTROL_LENGTH 32 +#define USB_SPECIFICATION 0x1001 +#define DEVICE_CLASS 0x00 +#define DEVICE_SUB_CLASS 0 +#define DEVICE_PROTOCOL 0 +#define EP_CONTROL_LENGTH 32 -#define VENDOR_ID 0xEB03 /* Atmel vendor ID = 03EBh */ -#define PRODUCT_ID 0x07FF /* Product ID: FF07h */ -#define RELEASE_NUMBER (0x0100*VER_UPDATE)+(0x1000*VER_MINOR)+(0x0001*VER_MAJOR) // 0x2021 //(VER_MAJOR)//((0x0000)|(VER_MAJOR<<24)|(VER_MINOR<<8)|(VER_UPDATE)) -#define NB_CONFIGURATION 1 +#define VENDOR_ID 0xEB03 /* Atmel vendor ID = 03EBh */ +#define PRODUCT_ID 0x07FF /* Product ID: FF07h */ +#define RELEASE_NUMBER (0x0100*VER_UPDATE)+(0x1000*VER_MINOR)+(0x0001*VER_MAJOR) // 0x2021 //(VER_MAJOR)//((0x0000)|(VER_MAJOR<<24)|(VER_MINOR<<8)|(VER_UPDATE)) +#define NB_CONFIGURATION 1 /* CONFIGURATION DESCRIPTOR */ -#define CONF_LENGTH 0xE800 // 232 -#define NB_INTERFACE 6 -#define CONF_NB 1 -#define CONF_ATTRIBUTES USB_CONFIG_BUSPOWERED -#define MAX_POWER 50 /* 100 mA */ +#define CONF_LENGTH 0xE800 // 232 +#define NB_INTERFACE 6 +#define CONF_NB 1 +#define CONF_ATTRIBUTES USB_CONFIG_BUSPOWERED +#define MAX_POWER 50 /* 100 mA */ -#define LANG_ID 0x00 -#define LANGUAGE_ID 0x0904 +#define LANG_ID 0x00 +#define LANGUAGE_ID 0x0904 -#define EP_CONTROL 0x00 -#define EP_IN 0x01 -#define EP_KBD_IN EP_IN -#define EP_IN_LENGTH 64 -#define ENDPOINT_0 0x00 -#define ENDPOINT_1 0x81 +#define EP_CONTROL 0x00 +#define EP_IN 0x01 +#define EP_KBD_IN EP_IN +#define EP_IN_LENGTH 64 +#define ENDPOINT_0 0x00 +#define ENDPOINT_1 0x81 -#define RX_EP 2 -#define TX_EP 1 -#define TX_EP_SIZE 32 +#define RX_EP 2 +#define TX_EP 1 +#define TX_EP_SIZE 32 /* STRING INDEX */ /*******************************************/ -#define MAN_STRING_INDEX 1 -#define PROD_STRING_INDEX 2 -#define SN_STRING_INDEX 3 -#define CONFIG_STRING_INDEX 4 +#define MAN_STRING_INDEX 1 +#define PROD_STRING_INDEX 2 +#define SN_STRING_INDEX 3 +#define CONFIG_STRING_INDEX 4 #define USB_MANUFACTURER_NAME {'K'<<8, 'y'<<8, 's'<<8, 'o'<<8, 'h'<<8} -#define USB_MN_LENGTH 5 +#define USB_MN_LENGTH 5 -#define USB_PRODUCT_NAME {'T'<<8, 'u'<<8, 'x'<<8, ' '<<8, 'D'<<8, \ +#define USB_PRODUCT_NAME {'T'<<8, 'u'<<8, 'x'<<8, ' '<<8, 'D'<<8, \ 'r'<<8, 'o'<<8, 'i'<<8, 'd'<<8} -#define USB_PN_LENGTH 9 +#define USB_PN_LENGTH 9 -#define USB_SERIAL_NUMBER {'1'<<8, '0'<<8, '0'<<8, '0'<<8, '1'<<8} -#define USB_SN_LENGTH 5 +#define USB_SERIAL_NUMBER {'1'<<8, '0'<<8, '0'<<8, '0'<<8, '1'<<8} +#define USB_SN_LENGTH 5 -#define USB_CONFIG_NAME {'T'<<8, 'u'<<8, 'x'<<8, ' '<<8, 'D'<<8, \ +#define USB_CONFIG_NAME {'T'<<8, 'u'<<8, 'x'<<8, ' '<<8, 'D'<<8, \ 'r'<<8, 'o'<<8, 'i'<<8, 'd'<<8} -#define USB_CONFIG_LENGTH 9 +#define USB_CONFIG_LENGTH 9 -#define LANG_ID 0x00 -#define LANGUAGE_ID 0x0904 +#define LANG_ID 0x00 +#define LANGUAGE_ID 0x0904 /*_____ D E C L A R A T I O N ______________________________________________*/ Modified: firmware/fuxusb/trunk/global.c =================================================================== --- firmware/fuxusb/trunk/global.c 2007-10-02 21:03:04 UTC (rev 576) +++ firmware/fuxusb/trunk/global.c 2007-10-02 21:18:59 UTC (rev 577) @@ -1,13 +1,13 @@ /*C************************************************************************** -* NAME: global.c +* NAME: global.c *---------------------------------------------------------------------------- * Copyright (c) 2006 C2me. *---------------------------------------------------------------------------- -* RELEASE: c5131-usb-RF Dongle -* REVISION: 1.3 +* RELEASE: c5131-usb-RF Dongle +* REVISION: 1.3 *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: *---------------------------------------------------------------------------- * $Id$ *****************************************************************************/ @@ -23,41 +23,41 @@ /*_____ D E C L A R A T I O N ______________________________________________*/ //------------------------------------------------------- -// SPI Controler +// SPI Controler //------------------------------------------------------- -bit spi_task_on_Flag; // = 1; // to turn ON the RF Task +bit spi_task_on_Flag; // = 1; // to turn ON the RF Task - // = 0; // to turn OFF the RF Task + // = 0; // to turn OFF the RF Task //------------------------------------------------------- -// USB Controler +// USB Controler //------------------------------------------------------- unsigned int usb_sof_counter; unsigned char usb_configuration_nb; bit usb_connected_Flag; -bit CMD_OUT_usb_Bank; // To store the number of the Bank used for the CMD_OUT Endpoint +bit CMD_OUT_usb_Bank; // To store the number of the Bank used for the CMD_OUT Endpoint char CMD_IN_Bank_Nb; bit USB_ParserProcess_Permit_Flag; //------------------------------------------------------- -// I2C Controler +// I2C Controler //------------------------------------------------------- unsigned char i2c_wait_counter = 0; bit i2c_task_on_Flag; //------------------------------------------------------- -// RF Controler +// RF Controler //------------------------------------------------------- //------------------------------------------------------- -// RF Header +// RF Header //------------------------------------------------------- -#define RF_2FRAMES_HDR 0x80 -#define RF_AUDIO_HDR 0x02 -#define RF_CMD_HDR 0x08 +#define RF_2FRAMES_HDR 0x80 +#define RF_AUDIO_HDR 0x02 +#define RF_CMD_HDR 0x08 //------------------------------------------------------- @@ -71,7 +71,7 @@ unsigned int spi_watchdog_ctr; //------------------------------------------------------- -// Tux Command and Status +// Tux Command and Status //------------------------------------------------------- unsigned char Tux_ID[2]; @@ -79,16 +79,16 @@ bit Tux_RequestingID_Flag; bit Tux_ChangingID_Flag; - // From USB + // From USB //------------------------------------------------------- -unsigned char USBCommand_ForDongle[65]; // For Dongle -unsigned char USBCommand_ForRF[65]; // For RF -unsigned char USBCommand_Ctr; // Store the number of byte sent by the LIBUSB +unsigned char USBCommand_ForDongle[65]; // For Dongle +unsigned char USBCommand_ForRF[65]; // For RF +unsigned char USBCommand_Ctr; // Store the number of byte sent by the LIBUSB bit USBCommand_NewRequest_Flag; -unsigned char USBCommand_Header; // Needed to analyze the LIBUSB command : to RF or to I2C +unsigned char USBCommand_Header; // Needed to analyze the LIBUSB command : to RF or to I2C //------------------------------------------------------- -// Dongle Info +// Dongle Info //------------------------------------------------------- code version_t info_version = { VERSION_CMD, VER_MAJOR, VER_MINOR, VER_UPDATE }; Modified: firmware/fuxusb/trunk/global.h =================================================================== --- firmware/fuxusb/trunk/global.h 2007-10-02 21:03:04 UTC (rev 576) +++ firmware/fuxusb/trunk/global.h 2007-10-02 21:18:59 UTC (rev 577) @@ -1,13 +1,13 @@ /*C************************************************************************** -* NAME: global.h +* NAME: global.h *---------------------------------------------------------------------------- * Copyright (c) 2006 C2me. *---------------------------------------------------------------------------- -* RELEASE: c5131-usb-RF Dongle -* REVISION: 1.3 +* RELEASE: c5131-usb-RF Dongle +* REVISION: 1.3 *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: * *****************************************************************************/ @@ -21,52 +21,52 @@ /*_____ D E F I N I T I O N ________________________________________________*/ // Hardware -#define rf_reset_signal P0_1 -#define RF_OFFLINE P2_3 +#define rf_reset_signal P0_1 +#define RF_OFFLINE P2_3 /*_____ D E C L A R A T I O N ______________________________________________*/ extern unsigned int Sleep_Ctr; //------------------------------------------------------- -// SPI Controler +// SPI Controler //------------------------------------------------------- -extern bit spi_task_on_Flag; // = 1; // to turn ON the RF Task +extern bit spi_task_on_Flag; // = 1; // to turn ON the RF Task - // = 0; // to turn OFF the RF Task + // = 0; // to turn OFF the RF Task extern unsigned int spi_watchdog_ctr; #define SPI_WATCHDOG_MAX (6000) //------------------------------------------------------- -// USB Controler +// USB Controler //------------------------------------------------------- extern unsigned int usb_sof_counter; extern unsigned char usb_configuration_nb; extern bit usb_connected_Flag; -extern bit CMD_OUT_usb_Bank; // To store the number of the Bank used for the CMD_OUT Endpoint +extern bit CMD_OUT_usb_Bank; // To store the number of the Bank used for the CMD_OUT Endpoint extern char CMD_IN_Bank_Nb; extern bit USB_ParserProcess_Permit_Flag; //------------------------------------------------------- -// I2C Controler +// I2C Controler //------------------------------------------------------- extern unsigned char i2c_wait_counter; extern bit i2c_task_on_Flag; //------------------------------------------------------- -// RF Controler +// RF Controler //------------------------------------------------------- -// RF Header +// RF Header //------------------------------------------------------- -#define RF_2FRAMES_HDR 0x80 -#define RF_AUDIO_HDR 0x02 -#define RF_CMD_HDR 0x08 -#define RF_INIT_FRAME 0x40 +#define RF_2FRAMES_HDR 0x80 +#define RF_AUDIO_HDR 0x02 +#define RF_CMD_HDR 0x08 +#define RF_INIT_FRAME 0x40 //------------------------------------------------------- @@ -77,35 +77,35 @@ extern unsigned char RF_InitFrame[]; extern unsigned char RF_Connection_Status; -#define RF_DISCONNECTED 0 -#define RF_TO_CONNECT 1 -#define RF_REQUEST_ID 2 -#define RF_CHANGE_ID 3 -#define RF_CONNECTED 4 +#define RF_DISCONNECTED 0 +#define RF_TO_CONNECT 1 +#define RF_REQUEST_ID 2 +#define RF_CHANGE_ID 3 +#define RF_CONNECTED 4 //------------------------------------------------------- -// Tux Command and Status +// Tux Command and Status //------------------------------------------------------- extern unsigned char Tux_ID[]; extern unsigned char Tux_NewID[]; extern bit Tux_RequestingID_Flag; extern bit Tux_ChangingID_Flag; - // From USB + // From USB //------------------------------------------------------- -extern unsigned char USBCommand_ForRF[]; // Store the USB Command -extern unsigned char USBCommand_ForDongle[]; // For Dongle -extern unsigned char USBCommand_Ctr; // Store the number of byte sent by the LIBUSB +extern unsigned char USBCommand_ForRF[]; // Store the USB Command +extern unsigned char USBCommand_ForDongle[]; // For Dongle +extern unsigned char USBCommand_Ctr; // Store the number of byte sent by the LIBUSB extern bit USBCommand_NewRequest_Flag; extern unsigned char USBCommand_Header; // Needed to analyze the LIBUSB command : to RF or to I2C -#define LIBUSB_TUX_CMD_HDR 0 -#define LIBUSB_DONGLE_CMD_HDR 1 -#define LIBUSB_BOOTLOADER_CMD_HDR 2 +#define LIBUSB_TUX_CMD_HDR 0 +#define LIBUSB_DONGLE_CMD_HDR 1 +#define LIBUSB_BOOTLOADER_CMD_HDR 2 //------------------------------------------------------- -// Dongle Info +// Dongle Info //------------------------------------------------------- extern code version_t info_version; Modified: firmware/fuxusb/trunk/i2c.c =================================================================== --- firmware/fuxusb/trunk/i2c.c 2007-10-02 21:03:04 UTC (rev 576) +++ firmware/fuxusb/trunk/i2c.c 2007-10-02 21:18:59 UTC (rev 577) @@ -42,7 +42,7 @@ void i2cSetBitrate(void) { /* Setting SSCON based on TWI_SCAL defined in i2c.h */ - SSCON = TWI_SCAL_VALUE; /* twi intialisation */ + SSCON = TWI_SCAL_VALUE; /* twi intialisation */ } /* @@ -55,18 +55,18 @@ void i2cInit(void) { /* Set up twi */ - SSCON = TWI_SSIE | TWI_SCAL_VALUE; /* enable TWI */ + SSCON = TWI_SSIE | TWI_SCAL_VALUE; /* enable TWI */ #ifdef TWI_INT_ENABLED Enable_twi_interrupt(); #endif -#ifdef TWI_SLA_ENABLED /* If Slave mode: */ +#ifdef TWI_SLA_ENABLED /* If Slave mode: */ /* Set local device address (used in slave mode only) */ SSADR = I2C_SLA_ADD; /* Enabling Slave mode */ - TWI_SET_AA(); /* enable TWI ACK */ - i2cSlaveReceive = 0; /* XXX do we need those 2 lines? clear SlaveReceive and SlaveTransmit handler to null */ + TWI_SET_AA(); /* enable TWI ACK */ + i2cSlaveReceive = 0; /* XXX do we need those 2 lines? clear SlaveReceive and SlaveTransmit handler to null */ i2cSlaveTransmit = 0; #endif @@ -97,7 +97,7 @@ void i2cMasterStart(void) { i2cFlags.i2c_busy = 1; - i2cSendDataIndex = 0; /* don't forget to reset the index */ + i2cSendDataIndex = 0; /* don't forget to reset the index */ i2cSendStart(); } @@ -127,7 +127,7 @@ TWI_CLEAR_AA(); } -#define TW_DATA SSDAT +#define TW_DATA SSDAT uint8_t i2cGetReceivedByte(void) { return SSDAT; @@ -139,7 +139,7 @@ } #ifdef __debug__ -uint8_t i2cStatus[20]; /* debug only */ +uint8_t i2cStatus[20]; /* debug only */ uint8_t i2cStatusIdx = 0; #endif @@ -157,8 +157,8 @@ switch (TW_STATUS) { /* * * Master General * * */ - case TW_START: // 0x08: Sent start condition - case TW_REP_START: // 0x10: Sent repeated start condition + case TW_START: // 0x08: Sent start condition + case TW_REP_START: // 0x10: Sent repeated start condition #if I2C_DEBUG #endif // send device address @@ -168,14 +168,14 @@ /* * * Master Transmitter & Receiver status codes * * */ - case TW_MT_SLA_ACK: // 0x18: Slave address acknowledged - case TW_MT_DATA_ACK: // 0x28: Data acknowledged + case TW_MT_SLA_ACK: // 0x18: Slave address acknowledged + case TW_MT_DATA_ACK: // 0x28: Data acknowledged #if I2C_DEBUG #endif if (i2cSendDataIndex < i2cSendDataLength) { - i2cSendByte(i2cSendData[i2cSendDataIndex++]); /* send data */ + i2cSendByte(i2cSendData[i2cSendDataIndex++]); /* send data */ } else { @@ -186,89 +186,89 @@ case TW_MR_DATA_NACK: // 0x58: Data received, NACK reply issued #if I2C_DEBUG #endif - i2cReceiveData[i2cReceiveDataIndex++] = TW_DATA; // store final received data byte + i2cReceiveData[i2cReceiveDataIndex++] = TW_DATA; // store final received data byte /* no break, continue to transmit STOP condition */ - case TW_MR_SLA_NACK: // 0x48: Slave address not acknowledged - case TW_MT_SLA_NACK: // 0x20: Slave address not acknowledged + case TW_MR_SLA_NACK: // 0x48: Slave address not acknowledged + case TW_MT_SLA_NACK: // 0x20: Slave address not acknowledged case TW_MT_DATA_NACK: // 0x30: Data not acknowledged #if I2C_DEBUG #endif i2cFlags.mt_nack = 1; i2cSendStop(); break; - case TW_MT_ARB_LOST: // 0x38: Bus arbitration lost - //case TW_MR_ARB_LOST: // 0x38: Bus arbitration lost + case TW_MT_ARB_LOST: // 0x38: Bus arbitration lost + //case TW_MR_ARB_LOST: // 0x38: Bus arbitration lost #if I2C_DEBUG #endif i2cInit(); break; - case TW_MR_DATA_ACK: // 0x50: Data acknowledged + case TW_MR_DATA_ACK: // 0x50: Data acknowledged #if I2C_DEBUG #endif // store received data byte i2cReceiveData[i2cReceiveDataIndex++] = TW_DATA; // fall-through to see if more bytes will be received - case TW_MR_SLA_ACK: // 0x40: Slave address acknowledged + case TW_MR_SLA_ACK: // 0x40: Slave address acknowledged #if I2C_DEBUG #endif if (i2cReceiveDataIndex < (i2cReceiveDataLength - 1)) - i2cAckReceiveByte(); /* receive more bytes */ + i2cAckReceiveByte(); /* receive more bytes */ else - i2cNackReceiveByte(); /* receive the last byte */ + i2cNackReceiveByte(); /* receive the last byte */ break; /* * * Slave Receiver status codes * * */ - case TW_SR_SLA_ACK: // 0x60: own SLA+W has been received, ACK has been returned - case TW_SR_ARB_LOST_SLA_ACK: // 0x68: own SLA+W has been received, ACK has been returned - case TW_SR_GCALL_ACK: // 0x70: GCA+W has been received, ACK has been returned - case TW_SR_ARB_LOST_GCALL_ACK: // 0x78: GCA+W has been received, ACK has been returned + case TW_SR_SLA_ACK: // 0x60: own SLA+W has been received, ACK has been returned + case TW_SR_ARB_LOST_SLA_ACK: // 0x68: own SLA+W has been received, ACK has been returned + case TW_SR_GCALL_ACK: // 0x70: GCA+W has been received, ACK has been returned + case TW_SR_ARB_LOST_GCALL_ACK: // 0x78: GCA+W has been received, ACK has been returned #if I2C_DEBUG #endif /* we are being addressed as slave for writing (data will be received from master) */ i2cFlags.i2c_busy = 1; i2cReceiveDataIndex = 0; - i2cFlags.s_nack = 0; /* reset nack flag here, not in user app */ - i2cAckReceiveByte(); /* accept data */ + i2cFlags.s_nack = 0; /* reset nack flag here, not in user app */ + i2cAckReceiveByte(); /* accept data */ break; - case TW_SR_DATA_ACK: // 0x80: data byte has been received, ACK has been returned - case TW_SR_GCALL_DATA_ACK: // 0x90: data byte has been received, ACK has been returned + case TW_SR_DATA_ACK: // 0x80: data byte has been received, ACK has been returned + case TW_SR_GCALL_DATA_ACK: // 0x90: data byte has been received, ACK has been returned #if I2C_DEBUG #endif - i2cReceiveData[i2cReceiveDataIndex++] = TW_DATA; /* get received data byte */ + i2cReceiveData[i2cReceiveDataIndex++] = TW_DATA; /* get received data byte */ /* check receive buffer status */ if (i2cReceiveDataIndex < I2C_RECEIVE_DATA_BUFFER_SIZE) { - i2cAckReceiveByte(); /* accept more data */ + i2cAckReceiveByte(); /* accept more data */ } else { - i2cNackReceiveByte(); /* refuse more data */ + i2cNackReceiveByte(); /* refuse more data */ } break; case TW_SR_DATA_NACK: // 0x88: data byte has been received, NACK has been returned - case TW_SR_GCALL_DATA_NACK: // 0x98: data byte has been received, NACK has been returned + case TW_SR_GCALL_DATA_NACK: // 0x98: data byte has been received, NACK has been returned #if I2C_DEBUG #endif //i2cReceiveData[i2cReceiveDataIndex++] = TW_DATA; /* receive last byte XXX check if this is right */ //i2cNackReceiveByte(); //XXX bug here? // receive data byte and return NACK //i2cAckReceiveByte(); [> I should clear the interrupt and enable acknoledge for slave mode (disabled during previous nack) <] - i2cFlags.s_nack = 1; /* XXX check if this flag is reset in all possible conditions */ + i2cFlags.s_nack = 1; /* XXX check if this flag is reset in all possible conditions */ //break; /* pass along to restart slave mode */ - case TW_SR_STOP: // 0xA0: STOP or REPEATED START has been received while addressed as slave + case TW_SR_STOP: // 0xA0: STOP or REPEATED START has been received while addressed as slave #if I2C_DEBUG #endif - i2cInit(); /* enable TWI ACK */ + i2cInit(); /* enable TWI ACK */ if (i2cSlaveReceive) - i2cSlaveReceive(i2cReceiveDataIndex, i2cReceiveData); /* i2c receive is complete, call i2cSlaveReceive */ - i2cFlags.i2c_busy = 0; /* XXX check if this flag is reset in all possible conditions */ + i2cSlaveReceive(i2cReceiveDataIndex, i2cReceiveData); /* i2c receive is complete, call i2cSlaveReceive */ + i2cFlags.i2c_busy = 0; /* XXX check if this flag is reset in all possible conditions */ break; /* * * Slave Transmitter * * */ - case TW_ST_SLA_ACK: // 0xA8: own SLA+R has been received, ACK has been returned - case TW_ST_ARB_LOST_SLA_ACK: // 0xB0: GCA+R has been received, ACK has been returned + case TW_ST_SLA_ACK: // 0xA8: own SLA+R has been received, ACK has been returned + case TW_ST_ARB_LOST_SLA_ACK: // 0xB0: GCA+R has been received, ACK has been returned #if I2C_DEBUG #endif // we are being addressed as slave for reading (data must be transmitted back to master) @@ -276,36 +276,36 @@ if (i2cSlaveTransmit) i2cSendDataLength = i2cSlaveTransmit(I2C_SEND_DATA_BUFFER_SIZE, i2cSendData); - i2cSendDataIndex = 0; /* reset data index */ + i2cSendDataIndex = 0; /* reset data index */ /* fall-through to transmit first data byte */ - case TW_ST_DATA_ACK: // 0xB8: data byte has been transmitted, ACK has been received + case TW_ST_DATA_ACK: // 0xB8: data byte has been transmitted, ACK has been received #if I2C_DEBUG #endif TW_DATA = i2cSendData[i2cSendDataIndex++]; /* transmit data byte */ if (i2cSendDataIndex < i2cSendDataLength) - i2cAckReceiveByte(); /* expect ACK to data byte */ + i2cAckReceiveByte(); /* expect ACK to data byte */ else - i2cNackReceiveByte(); /* expect NACK to data byte */ + i2cNackReceiveByte(); /* expect NACK to data byte */ break; case TW_ST_DATA_NACK: // 0xC0: data byte has been transmitted, NACK has been received case TW_ST_LAST_DATA: // 0xC8: last data byte transmitted, ACK received #if I2C_DEBUG #endif /* all done, switch to open slave */ - i2cInit(); /* enable TWI ACK */ + i2cInit(); /* enable TWI ACK */ break; /* * * Misc * * */ - case TW_NO_INFO: // 0xF8: No relevant state information + case TW_NO_INFO: // 0xF8: No relevant state information /* do nothing */ #if I2C_DEBUG #endif break; - case TW_BUS_ERROR: // 0x00: Bus error due to illegal start or stop condition + case TW_BUS_ERROR: // 0x00: Bus error due to illegal start or stop condition #if I2C_DEBUG #endif - i2cSendStop(); /* reset internal hardware and release bus */ + i2cSendStop(); /* reset internal hardware and release bus */ break; } TWI_CLEAR_SI(); Modified: firmware/fuxusb/trunk/i2c.h =================================================================== --- firmware/fuxusb/trunk/i2c.h 2007-10-02 21:03:04 UTC (rev 576) +++ firmware/fuxusb/trunk/i2c.h 2007-10-02 21:18:59 UTC (rev 577) @@ -14,27 +14,27 @@ #include "config.h" #ifdef __debug__ -extern uint8_t i2cStatus[20]; /* XXX debug only */ +extern uint8_t i2cStatus[20]; /* XXX debug only */ extern uint8_t i2cStatusIdx; #endif /* * * include custom configuration here * * */ -#define I2C_SEND_DATA_BUFFER_SIZE 130 -#define I2C_RECEIVE_DATA_BUFFER_SIZE 8 +#define I2C_SEND_DATA_BUFFER_SIZE 130 +#define I2C_RECEIVE_DATA_BUFFER_SIZE 8 /* * Choose operation mode, comment/uncomment lines * For Slave only operation, choose Master and Slave */ -#define TWI_INT_ENABLED /* comment if you don't want twi interrupts */ -#define TWI_M_ENABLED /* comment if you don't want twi master mode */ +#define TWI_INT_ENABLED /* comment if you don't want twi interrupts */ +#define TWI_M_ENABLED /* comment if you don't want twi master mode */ //#define TWI_SLA_ENABLED /* comment if you don't want twi slave mode */ /* SSADR: TWI (Slave) Address Register * Bits 7..1 : TWI (Slave) Address Register * Bit 0 : TWI General Call Recognition Enable Bit */ -#define I2C_SLA_ADD ((0X55<<1) | 0x01) /* Only necessary in slave mode */ +#define I2C_SLA_ADD ((0X55<<1) | 0x01) /* Only necessary in slave mode */ /* * Initialise TWI clock @@ -46,31 +46,31 @@ */ //#define TWI_SCAL 160 /* TWI_SCAL value should be: 256 224 192 160 960 120 60 */ -#define TWI_SCAL 960 /* TWI_SCAL value should be: 256 224 192 160 960 120 60 */ +#define TWI_SCAL 960 /* TWI_SCAL value should be: 256 224 192 160 960 120 60 */ /* * * END of code customisation * * */ #if TWI_SCAL == 256 -#define TWI_SCAL_VALUE TWI_RATIO_256 +#define TWI_SCAL_VALUE TWI_RATIO_256 #elif TWI_SCAL == 224 -#define TWI_SCAL_VALUE TWI_RATIO_224 +#define TWI_SCAL_VALUE TWI_RATIO_224 #elif TWI_SCAL == 192 -#define TWI_SCAL_VALUE TWI_RATIO_192 +#define TWI_SCAL_VALUE TWI_RATIO_192 #elif TWI_SCAL == 160 -#define TWI_SCAL_VALUE TWI_RATIO_160 +#define TWI_SCAL_VALUE TWI_RATIO_160 #elif TWI_SCAL == 960 -#define TWI_SCAL_VALUE TWI_RATIO_960 +#define TWI_SCAL_VALUE TWI_RATIO_960 #elif TWI_SCAL == 120 -#define TWI_SCAL_VALUE TWI_RATIO_120 +#define TWI_SCAL_VALUE TWI_RATIO_120 #elif TWI_SCAL == 60 -#define TWI_SCAL_VALUE TWI_RATIO_60 +#define TWI_SCAL_VALUE TWI_RATIO_60 #else #error Incorrect TWI_SCAL value, should be: 256 224 192 160 960 120 60 #define TWI_SCAL_VALUE #endif /*! defines and constants */ -#define TWCR_CMD_MASK 0x0F +#define TWCR_CMD_MASK 0x0F /* * Bits that are set inside interrupt routines, and watched outside in @@ -78,13 +78,13 @@ */ typedef struct { - uint8_t i2c_busy:1; /* set when twi hardware is busy, cleared after an i2c stop */ - uint8_t mt_nack:1; /* error due to a nack received by the master transmitter */ - uint8_t s_nack:1; /* error due to a nack replied by the slave */ - uint8_t sr_end:1; /* set at the end of a receiver slave transmission if i2cSlaveReceive has not been defined */ - uint8_t st_end:1; /* set at the end of a transmitter slave transmission if i2cSlaveTransmit has not been defined */ - uint8_t i2c_idx:1; /* application side - can be used for data indexes status */ - uint8_t s_val:1; /* application side - can be used for data validation */ + uint8_t i2c_busy:1; /* set when twi hardware is busy, cleared after an i2c stop */ + uint8_t mt_nack:1; /* error due to a nack received by the master transmitter */ + uint8_t s_nack:1; /* error due to a nack replied by the slave */ + uint8_t sr_end:1; /* set at the end of a receiver slave transmission if i2cSlaveReceive has not been defined */ + uint8_t st_end:1; /* set at the end of a transmitter slave transmission if i2cSlaveTransmit has not been defined */ + uint8_t i2c_idx:1; /* application side - can be used for data indexes status */ + uint8_t s_val:1; /* application side - can be used for data validation */ } I2C_FLAGS; extern volatile I2C_FLAGS i2cFlags; Modified: firmware/fuxusb/trunk/main.c =================================================================== --- firmware/fuxusb/trunk/main.c 2007-10-02 21:03:04 UTC (rev 576) +++ firmware/fuxusb/trunk/main.c 2007-10-02 21:18:59 UTC (rev 577) @@ -1,13 +1,13 @@ /*C************************************************************************** -* NAME: main.c +* NAME: main.c *---------------------------------------------------------------------------- * Copyright (c) 2006 C2me. *---------------------------------------------------------------------------- -* RELEASE: c5131-usb-RF Dongle -* REVISION: 1.3 +* RELEASE: c5131-usb-RF Dongle +* REVISION: 1.3 *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: *---------------------------------------------------------------------------- * $Id$ *****************************************************************************/ @@ -35,18 +35,18 @@ /*_____ D E C L A R A T I O N S ____________________________________________*/ /*F************************************************************************** -* NAME: main +* NAME: main *---------------------------------------------------------------------------- -* PARAMS: none -* return: none +* PARAMS: none +* return: none *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: *---------------------------------------------------------------------------- * EXAMPLE: *---------------------------------------------------------------------------- -* NOTE: +* NOTE: *---------------------------------------------------------------------------- -* REQUIREMENTS: +* REQUIREMENTS: *****************************************************************************/ void main(void) { @@ -55,10 +55,10 @@ * * It is set when USB receives SET_CONGIGURATION command during * enumeration. RF is also disabled during bootload. */ - rf_reset_signal = 0; // Maintains the RF in RESET STATE until the USB has received the Command to connect RF + rf_reset_signal = 0; // Maintains the RF in RESET STATE until the USB has received the Command to connect RF // Go to 0 in usb_set_configuration() - // Stay Low During the I2C communication - RF_OFFLINE = 1; // Set Port to able to Read the Input Signal + // Stay Low During the I2C communication + RF_OFFLINE = 1; // Set Port to able to Read the Input Signal Set_x2_mode(); Modified: firmware/fuxusb/trunk/version.h =================================================================== --- firmware/fuxusb/trunk/version.h 2007-10-02 21:03:04 UTC (rev 576) +++ firmware/fuxusb/trunk/version.h 2007-10-02 21:18:59 UTC (rev 577) @@ -2,7 +2,7 @@ /* KySoH iTux agent * * Behavioural source code - * created on 2005/10/20 David Bourgeois + * created on 2005/10/20 David Bourgeois * -------------------------------------------------------- * */ @@ -14,11 +14,11 @@ * Version number */ -#define VER_MAJOR 1 -#define VER_MINOR 2 -#define VER_UPDATE 0 +#define VER_MAJOR 1 +#define VER_MINOR 2 +#define VER_UPDATE 0 -#define AUTHOR_ID 0 /* official release */ -#define REVISION_NUMBER 0xFFEE /* XXX find a way to define this automatically in the Makefile from SVN */ +#define AUTHOR_ID 0 /* official release */ +#define REVISION_NUMBER 0xFFEE /* XXX find a way to define this automatically in the Makefile from SVN */ #endif /* _VERSION_H_ */ |