[tuxdroid-svn] r579 - in firmware/fuxusb/trunk: lib_board lib_c lib_mcu lib_mcu/fa-usb lib_mcu/spi
Status: Beta
Brought to you by:
ks156
From: jaguarondi <c2m...@c2...> - 2007-10-03 11:21:35
|
Author: jaguarondi Date: 2007-10-03 13:19:59 +0200 (Wed, 03 Oct 2007) New Revision: 579 Modified: firmware/fuxusb/trunk/lib_board/c5131_evab.h firmware/fuxusb/trunk/lib_board/kbd_drv.c firmware/fuxusb/trunk/lib_board/kbd_drv.h firmware/fuxusb/trunk/lib_c/stdint.h firmware/fuxusb/trunk/lib_mcu/5131_drv.h firmware/fuxusb/trunk/lib_mcu/c51_drv.h firmware/fuxusb/trunk/lib_mcu/compiler.h firmware/fuxusb/trunk/lib_mcu/ext_5131.h firmware/fuxusb/trunk/lib_mcu/fa-usb/flash_api.c firmware/fuxusb/trunk/lib_mcu/fa-usb/flash_api.h firmware/fuxusb/trunk/lib_mcu/mcu.h firmware/fuxusb/trunk/lib_mcu/mcu_drv.h firmware/fuxusb/trunk/lib_mcu/reg_5131.h firmware/fuxusb/trunk/lib_mcu/spi/spi_lib.c firmware/fuxusb/trunk/lib_mcu/spi/spi_lib.h firmware/fuxusb/trunk/lib_mcu/twi/twi.h firmware/fuxusb/trunk/lib_mcu/uart/tools/c51_bdr.c firmware/fuxusb/trunk/lib_mcu/uart/uart_bdr.h firmware/fuxusb/trunk/lib_mcu/uart/uart_lib.c firmware/fuxusb/trunk/lib_mcu/uart/uart_lib.h firmware/fuxusb/trunk/lib_mcu/usb/uart_usb_lib.c firmware/fuxusb/trunk/lib_mcu/usb/uart_usb_lib.h firmware/fuxusb/trunk/lib_mcu/usb/usb_drv.c firmware/fuxusb/trunk/lib_mcu/usb/usb_drv.h firmware/fuxusb/trunk/modules/fifo/fifo.c firmware/fuxusb/trunk/modules/fifo/fifo.h firmware/fuxusb/trunk/modules/fifo/fifo_mic.c firmware/fuxusb/trunk/modules/fifo/fifo_mic.h firmware/fuxusb/trunk/modules/fifo/fifo_spk.c firmware/fuxusb/trunk/modules/fifo/fifo_spk.h firmware/fuxusb/trunk/modules/fifo_stt/fifo_stt.c firmware/fuxusb/trunk/modules/fifo_stt/fifo_stt.h firmware/fuxusb/trunk/modules/scheduler/scheduler.c firmware/fuxusb/trunk/modules/scheduler/scheduler.h firmware/fuxusb/trunk/modules/spi/spi_task.c firmware/fuxusb/trunk/modules/spi/spi_task.h firmware/fuxusb/trunk/modules/timer_soft/timer_soft.c firmware/fuxusb/trunk/modules/timer_soft/timer_soft.h firmware/fuxusb/trunk/modules/usb/usb_task.c firmware/fuxusb/trunk/modules/usb/usb_task.h firmware/fuxusb/trunk/modules/usb_enum/USB_ENUM.H firmware/fuxusb/trunk/modules/usb_enum/usb_enum.c Log: * Indentation was only performed on /, now done on subdirectories. Tabs and spaces have been cleaned. Indent command: indent $(find . -name '*.[ch]') -nut -i4 -bad -bap -bbb -sob -sc -bl -bli0 -cli0 -cbi4 -nce -ncdw -ss -bls -npsl -ncs -npcs -nprs -saf -sai -saw -nbfda -nhnl -l80 Modified: firmware/fuxusb/trunk/lib_board/c5131_evab.h =================================================================== --- firmware/fuxusb/trunk/lib_board/c5131_evab.h 2007-10-03 08:28:04 UTC (rev 578) +++ firmware/fuxusb/trunk/lib_board/c5131_evab.h 2007-10-03 11:19:59 UTC (rev 579) @@ -1,51 +1,48 @@ + /*H************************************************************************** -* NAME: c5131_evab.h +* NAME: c5131_evab.h *---------------------------------------------------------------------------- * Copyright (c) 2004 Atmel. *---------------------------------------------------------------------------- -* RELEASE: c5131-usb-cdc-1_0_2 -* REVISION: 1.8 +* RELEASE: c5131-usb-cdc-1_0_2 +* REVISION: 1.8 *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: * Configuration file. Selection of the device. *****************************************************************************/ #ifndef _C5131_EVAB_H #define _C5131_EVAB_H /*_____ D E F I N I T I O N S ______________________________________________*/ -#define GENEB_BUZZER P1_5 // CPU I/O Port connected to GENEB Buzzer Pin or mute -#define GENEB_BP1 P3_2 // CPU I/O Port connected to GENEB BP1 +#define GENEB_BUZZER P1_5 // CPU I/O Port connected to GENEB Buzzer Pin or mute +#define GENEB_BP1 P3_2 // CPU I/O Port connected to GENEB BP1 -#define GENEB_TWI_IT P3_2 // Port I/O IT pin of CPU connected to GENEB TWI_IT Pin -#define GENEB_SDA P1_1 -#define GENEB_SCL P1_0 +#define GENEB_TWI_IT P3_2 // Port I/O IT pin of CPU connected to GENEB TWI_IT Pin +#define GENEB_SDA P1_1 +#define GENEB_SCL P1_0 -#define GENEB_A16 P3_4 // CPU I/O Port connected to GENEB A16 -#define GENEB_CS_RAM P1_2 -#define GENEB_CS_FLASH P1_3 -#define GENEB_ISP_FLASH P1_4 +#define GENEB_A16 P3_4 // CPU I/O Port connected to GENEB A16 +#define GENEB_CS_RAM P1_2 +#define GENEB_CS_FLASH P1_3 +#define GENEB_ISP_FLASH P1_4 -#define RST_ETH P1_5 -#define CS_ETH P3_5 +#define RST_ETH P1_5 +#define CS_ETH P3_5 -#define CPUb_enable_all_leds() (AUXR&=~1,P3_0=0,P3_1=0,P4_0=0,P4_1=0,P1_5=0) +#define CPUb_enable_all_leds() (AUXR&=~1,P3_0=0,P3_1=0,P4_0=0,P4_1=0,P1_5=0) #define CPUb_disable_all_leds() (AUXR|=1,P3_0=1,P3_1=1,P4_0=1,P4_1=1,P1_5=1) -#define Geneb_enable_ram() (GENEB_ISP_FLASH=1,CS_ETH=1,GENEB_CS_RAM=0) -#define Geneb_disable_ram() (GENEB_CS_RAM=1) -#define Geneb_enable_isp() (GENEB_ISP_FLASH=0,GENEB_CS_FLASH=1) -#define Geneb_disable_isp() (GENEB_ISP_FLASH=1) +#define Geneb_enable_ram() (GENEB_ISP_FLASH=1,CS_ETH=1,GENEB_CS_RAM=0) +#define Geneb_disable_ram() (GENEB_CS_RAM=1) +#define Geneb_enable_isp() (GENEB_ISP_FLASH=0,GENEB_CS_FLASH=1) +#define Geneb_disable_isp() (GENEB_ISP_FLASH=1) /*_____ I N C L U D E S ____________________________________________________*/ #ifdef GENEB_VERSION #include "lib_board/geneb.h" #endif - /*_____ M A C R O S ________________________________________________________*/ /*_____ D E C L A R A T I O N S ____________________________________________*/ -#endif /* _C5131_EVAB_H */ - - - +#endif /* _C5131_EVAB_H */ Modified: firmware/fuxusb/trunk/lib_board/kbd_drv.c =================================================================== --- firmware/fuxusb/trunk/lib_board/kbd_drv.c 2007-10-03 08:28:04 UTC (rev 578) +++ firmware/fuxusb/trunk/lib_board/kbd_drv.c 2007-10-03 11:19:59 UTC (rev 579) @@ -1,12 +1,13 @@ + /*C************************************************************************** -* NAME: kbd_drv.c +* NAME: kbd_drv.c *---------------------------------------------------------------------------- * Copyright (c) 2004 Atmel. *---------------------------------------------------------------------------- -* RELEASE: c5131-usb-cdc-1_0_2 -* REVISION: 1.1 +* RELEASE: c5131-usb-cdc-1_0_2 +* REVISION: 1.1 *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: * This file contains C functions to control: * SWITCHES *****************************************************************************/ @@ -18,51 +19,44 @@ /*_____ M A C R O S ________________________________________________________*/ /*_____ D E F I N I T I O N S ______________________________________________*/ -#define KBD_COL_MASK 0x0F -#define KBD_COL0 0x08 -#define KBD_COL1 0x04 -#define KBD_COL2 0x02 -#define KBD_COL3 0x01 -#define KBD_ROW_MASK 0xF0 -#define KBD_ROW0 0x10 -#define KBD_ROW1 0x20 -#define KBD_ROW2 0x40 -#define KBD_ROW3 0x80 +#define KBD_COL_MASK 0x0F +#define KBD_COL0 0x08 +#define KBD_COL1 0x04 +#define KBD_COL2 0x02 +#define KBD_COL3 0x01 +#define KBD_ROW_MASK 0xF0 +#define KBD_ROW0 0x10 +#define KBD_ROW1 0x20 +#define KBD_ROW2 0x40 +#define KBD_ROW3 0x80 -#define DEFAULT_SWITCHES_VALUE 0xFF -#define DEFAULT_SCAN_KEY_VALUE 0 +#define DEFAULT_SWITCHES_VALUE 0xFF +#define DEFAULT_SCAN_KEY_VALUE 0 + /*_____ D E C L A R A T I O N S ____________________________________________*/ - /*V************************************************************************** * NAME: scan_key *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: * scan_key is a structure allowing easy byte/word access (Union16). * 16 keys on keypad in a 16-bit variable => all cases supported * Ex. for geneb: -* MSb LSb +* MSb LSb * 9 5 1 < * 6 2 > 0 7 3 V # 8 4 C *****************************************************************************/ -volatile Union16 idata scan_key; -Byte code geneb_keys[]= { 'C', '4', '8', '#', - 'V', '3', '7', '0', - '>', '2', '6', '*', - '<', '1', '5', '9' }; -void kbd_test_hit (void) +volatile Union16 idata scan_key; +Byte code geneb_keys[] = { 'C', '4', '8', '#', + 'V', '3', '7', '0', + '>', '2', '6', '*', + '<', '1', '5', '9' +}; +void kbd_test_hit(void) { - } - -bit kbd_init (void) +bit kbd_init(void) { - return 0; + return 0; } - - - - - - Modified: firmware/fuxusb/trunk/lib_board/kbd_drv.h =================================================================== --- firmware/fuxusb/trunk/lib_board/kbd_drv.h 2007-10-03 08:28:04 UTC (rev 578) +++ firmware/fuxusb/trunk/lib_board/kbd_drv.h 2007-10-03 11:19:59 UTC (rev 579) @@ -1,12 +1,13 @@ + /*H************************************************************************** -* NAME: kbd_drv.h +* NAME: kbd_drv.h *---------------------------------------------------------------------------- * Copyright (c) 2004 Atmel. *---------------------------------------------------------------------------- -* RELEASE: c5131-usb-cdc-1_0_2 -* REVISION: 1.1 +* RELEASE: c5131-usb-cdc-1_0_2 +* REVISION: 1.1 *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: * Include file of twi_common.c file *****************************************************************************/ #ifndef _KBD_DRV_H @@ -21,29 +22,27 @@ /*F************************************************************************** * NAME: get_switches *---------------------------------------------------------------------------- -* PARAMS: none -* return: Uchar: switches value +* PARAMS: none +* return: Uchar: switches value *---------------------------------------------------------------------------- * PURPOSE: * 0=SWITCH ON, 1= SWITCH OFF, MSB =SWITCH 8, LSB = SWITCH 1 *---------------------------------------------------------------------------- * EXAMPLE: *---------------------------------------------------------------------------- -* NOTE: +* NOTE: *---------------------------------------------------------------------------- -* REQUIREMENTS: +* REQUIREMENTS: *****************************************************************************/ - /*_____ D E C L A R A T I O N S ____________________________________________*/ -#define ROW_PORT KBF -#define ROW_ALL ((KBF & 0xF0)>>4) +#define ROW_PORT KBF +#define ROW_ALL ((KBF & 0xF0)>>4) -#define SELECT_COLUMN 0 /*the active level is 0*/ -#define FREE_COLUMN 1 +#define SELECT_COLUMN 0 /*the active level is 0 */ +#define FREE_COLUMN 1 /*FUNCTION PROTOTYPES*/ -#endif /* _KBD_DRV_H */ - +#endif /* _KBD_DRV_H */ Modified: firmware/fuxusb/trunk/lib_c/stdint.h =================================================================== --- firmware/fuxusb/trunk/lib_c/stdint.h 2007-10-03 08:28:04 UTC (rev 578) +++ firmware/fuxusb/trunk/lib_c/stdint.h 2007-10-03 11:19:59 UTC (rev 579) @@ -1,5 +1,6 @@ + /* - * ISO/IEC 9899:1999 7.18 Integer types <stdint.h> + * ISO/IEC 9899:1999 7.18 Integer types <stdint.h> */ #ifndef __STDINT_H_ @@ -11,7 +12,7 @@ Use [u]intN_t if you need exactly N bits. Since these typedefs are mandated by the C99 standard, they are preferred - over rolling your own typedefs. */ + over rolling your own typedefs. */ /* Integer types */ @@ -87,17 +88,17 @@ /** \ingroup avr_stdint signed int with at least 8 bits. */ -typedef int8_t int_least8_t; +typedef int8_t int_least8_t; /** \ingroup avr_stdint unsigned int with at least 8 bits. */ -typedef uint8_t uint_least8_t; +typedef uint8_t uint_least8_t; /** \ingroup avr_stdint signed int with at least 16 bits. */ -typedef int16_t int_least16_t; +typedef int16_t int_least16_t; /** \ingroup avr_stdint unsigned int with at least 16 bits. */ @@ -107,7 +108,7 @@ /** \ingroup avr_stdint signed int with at least 32 bits. */ -typedef int32_t int_least32_t; +typedef int32_t int_least32_t; /** \ingroup avr_stdint unsigned int with at least 32 bits. */ @@ -117,7 +118,7 @@ /** \ingroup avr_stdint signed int with at least 64 bits. */ -// typedef int64_t int_least64_t; +// typedef int64_t int_least64_t; /** \ingroup avr_stdint unsigned int with at least 64 bits. */ @@ -126,7 +127,6 @@ /*@}*/ - /** \name Fastest minimum-width integer types Integer types being usually fastest having at least the specified width */ @@ -174,7 +174,6 @@ /*@}*/ - /** \name Greatest-width integer types Types designating integer data capable of representing any value of any integer type in the corresponding signed or unsigned category */ @@ -270,6 +269,7 @@ /*@}*/ /** \name Limits of minimum-width integer types */ + /*@{*/ /** \ingroup avr_stdint @@ -458,8 +458,8 @@ #define PTRDIFF_MIN INT16_MIN +/* Limits of sig_atomic_t */ -/* Limits of sig_atomic_t */ /* signal.h is currently not implemented (not avr/signal.h) */ /** \ingroup avr_stdint @@ -472,25 +472,27 @@ #define SIG_ATOMIC_MIN INT8_MIN - /** \ingroup avr_stdint largest value a size_t can hold. */ #define SIZE_MAX (__CONCAT(INT16_MAX, U)) +/* Limits of wchar_t */ -/* Limits of wchar_t */ /* wchar.h is currently not implemented */ + /* #define WCHAR_MAX */ + /* #define WCHAR_MIN */ +/* Limits of wint_t */ -/* Limits of wint_t */ /* wchar.h is currently not implemented */ + /* #define WINT_MAX */ + /* #define WINT_MIN */ - #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */ #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) @@ -556,5 +558,4 @@ #endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */ - #endif /* _STDINT_H_ */ Modified: firmware/fuxusb/trunk/lib_mcu/5131_drv.h =================================================================== --- firmware/fuxusb/trunk/lib_mcu/5131_drv.h 2007-10-03 08:28:04 UTC (rev 578) +++ firmware/fuxusb/trunk/lib_mcu/5131_drv.h 2007-10-03 11:19:59 UTC (rev 579) @@ -1,10 +1,11 @@ + /*H************************************************************************** -* NAME: 5131_drv.h +* NAME: 5131_drv.h *---------------------------------------------------------------------------- * Copyright (c) 2004 Atmel. *---------------------------------------------------------------------------- -* RELEASE: c5131-usb-cdc-1_0_2 -* REVISION: 1.7 +* RELEASE: c5131-usb-cdc-1_0_2 +* REVISION: 1.7 *---------------------------------------------------------------------------- * PURPOSE: * This file contains the C51 driver definition @@ -13,236 +14,230 @@ #ifndef _5131_DRV_H_ #define _5131_DRV_H_ -/*_____ I N C L U D E S ____________________________________________________*/ +/* INCLUDES */ +/* MACROS */ -/*_____ M A C R O S ________________________________________________________*/ +/* DEFINITION */ - -/*_____ D E F I N I T I O N ________________________________________________*/ /* SYSTEM MANAGEMENT */ -#define MSK_SMOD1 0x80 /* PCON */ -#define MSK_SMOD0 0x40 -#define MSK_GF1 0x08 -#define MSK_GF0 0x04 -#define MSK_PD 0x02 -#define MSK_IDL 0x01 +#define MSK_SMOD1 0x80 /* PCON */ +#define MSK_SMOD0 0x40 +#define MSK_GF1 0x08 +#define MSK_GF0 0x04 +#define MSK_PD 0x02 +#define MSK_IDL 0x01 -#define MSK_EXT16 0x40 /* AUXR */ -#define MSK_M0 0x20 -#define MSK_DPHDIS 0x10 -#define MSK_XRS 0x0C -#define MSK_EXTRAM 0x02 -#define MSK_AO 0x01 -#define ERAM_256 0x00 -#define ERAM_512 0x04 -#define ERAM_1024 0x08 -#define ERAM_2048 0x0C +#define MSK_EXT16 0x40 /* AUXR */ +#define MSK_M0 0x20 +#define MSK_DPHDIS 0x10 +#define MSK_XRS 0x0C +#define MSK_EXTRAM 0x02 +#define MSK_AO 0x01 +#define ERAM_256 0x00 +#define ERAM_512 0x04 +#define ERAM_1024 0x08 +#define ERAM_2048 0x0C - /* PLL & CLOCK */ -#define MSK_X2 0x01 /* CKCON */ -#define MSK_T0X2 0x02 -#define MSK_T1X2 0x04 -#define MSK_WDX2 0x40 +#define MSK_X2 0x01 /* CKCON */ +#define MSK_T0X2 0x02 +#define MSK_T1X2 0x04 +#define MSK_WDX2 0x40 - /* TIMERS */ -#define MSK_GATE1 0x80 /* TMOD */ -#define MSK_C_T1 0x40 -#define MSK_MO1 0x30 -#define MSK_GATE0 0x08 -#define MSK_C_T0 0x04 -#define MSK_MO0 0x03 +#define MSK_GATE1 0x80 /* TMOD */ +#define MSK_C_T1 0x40 +#define MSK_MO1 0x30 +#define MSK_GATE0 0x08 +#define MSK_C_T0 0x04 +#define MSK_MO0 0x03 - /* WATCHDOG */ -#define MSK_WTO 0x07 /* WDTPRG*/ +#define MSK_WTO 0x07 /* WDTPRG */ -/*_____ D E C L A R A T I O N ______________________________________________*/ +/* DECLARATION */ -#define Set_x2_mode() (CKCON0 |= MSK_X2) -#define Set_x1_mode() (CKCON0 &= ~MSK_X2) -#define Mode_x2() ((CKCON0 & MSK_X2) == MSK_X2) +#define Set_x2_mode() (CKCON0 |= MSK_X2) +#define Set_x1_mode() (CKCON0 &= ~MSK_X2) +#define Mode_x2() ((CKCON0 & MSK_X2) == MSK_X2) -#define Set_timer0_x1_mode() (CKCON0 |= MSK_T0X2) -#define Set_timer0_x2_mode() (CKCON0 &=~MSK_T0X2) -#define Set_timer1_x1_mode() (CKCON0 |= MSK_T1X2) -#define Set_timer1_x2_mode() (CKCON0 &=~MSK_T1X2) -#define Set_timer2_x1_mode() (CKCON0 |= MSK_T2X2) -#define Set_timer2_x2_mode() (CKCON0 &=~MSK_T2X2) -#define Set_uart_x1_mode() (CKCON0 |= MSK_UARTX2) -#define Set_uart_x2_mode() (CKCON0 &=~MSK_UARTX2) -#define Set_pca_x1_mode() (CKCON0 |= MSK_PCAX2) -#define Set_pca_x2_mode() (CKCON0 &=~MSK_PCAX2) +#define Set_timer0_x1_mode() (CKCON0 |= MSK_T0X2) +#define Set_timer0_x2_mode() (CKCON0 &=~MSK_T0X2) +#define Set_timer1_x1_mode() (CKCON0 |= MSK_T1X2) +#define Set_timer1_x2_mode() (CKCON0 &=~MSK_T1X2) +#define Set_timer2_x1_mode() (CKCON0 |= MSK_T2X2) +#define Set_timer2_x2_mode() (CKCON0 &=~MSK_T2X2) +#define Set_uart_x1_mode() (CKCON0 |= MSK_UARTX2) +#define Set_uart_x2_mode() (CKCON0 &=~MSK_UARTX2) +#define Set_pca_x1_mode() (CKCON0 |= MSK_PCAX2) +#define Set_pca_x2_mode() (CKCON0 &=~MSK_PCAX2) -#define Set_spi_x1_mode() (CKCON1 |= MSK_SPIX2) -#define Set_spi_x2_mode() (CKCON1 &=~MSK_SPIX2) +#define Set_spi_x1_mode() (CKCON1 |= MSK_SPIX2) +#define Set_spi_x2_mode() (CKCON1 &=~MSK_SPIX2) -#define Set_idle_mode() (PCON |= MSK_IDLE) -#define Set_power_down_mode() (PCON |= MSK_PD) +#define Set_idle_mode() (PCON |= MSK_IDLE) +#define Set_power_down_mode() (PCON |= MSK_PD) -#define Enable_eram() (AUXR &= ~MSK_EXTRAM) -#define Disable_eram() (AUXR |= MSK_EXTRAM) -#define Set_eram_size(s) ((AUXR &= ~MSK_XRS),(AUXR |= s)) +#define Enable_eram() (AUXR &= ~MSK_EXTRAM) +#define Disable_eram() (AUXR |= MSK_EXTRAM) +#define Set_eram_size(s) ((AUXR &= ~MSK_XRS),(AUXR |= s)) -#define Enable_interrupt() (EA = 1) -#define Disable_interrupt() (EA = 0) +#define Enable_interrupt() (EA = 1) +#define Disable_interrupt() (EA = 0) -#define Enable_twi_interrupt() (IEN1 |= 0x02) +#define Enable_twi_interrupt() (IEN1 |= 0x02) #define Disable_twi_interrupt() (IEN1 &= 0xFD) -#define Enable_spi_interrupt() (IEN1 |= 0x04) +#define Enable_spi_interrupt() (IEN1 |= 0x04) #define Disable_spi_interrupt() (IEN1 &= ~0x04) -#define Disable_ale() (AUXR |= MSK_AO) -#define Enable_ale() (AUXR &= ~MSK_AO) -#define Switch_ale() (AUXR ^= MSK_AO) +#define Disable_ale() (AUXR |= MSK_AO) +#define Enable_ale() (AUXR &= ~MSK_AO) +#define Switch_ale() (AUXR ^= MSK_AO) -#define STANDARD_PORT 0 -#define LED_PORT_2MA 1 -#define LED_PORT_4MA 2 -#define LED_PORT_10MA 3 +#define STANDARD_PORT 0 +#define LED_PORT_2MA 1 +#define LED_PORT_4MA 2 +#define LED_PORT_10MA 3 #define Configure_led(num,type) {LEDCON &= (0xFF & ~(0x03 << (num*2))); \ LEDCON |= (type << (num*2));} -#define Led_0_on() (P3_3 = 0) -#define Led_0_off() (P3_3 = 1) -#define Led_0_toggle() (P3_3 = ~P3_3) -#define Led_0_status() (P3_3) -#define Led_0_write(x) (P3_3 = x) -#define Led_1_on() (P3_5 = 0) -#define Led_1_off() (P3_5 = 1) -#define Led_1_toggle() (P3_5 = ~P3_5) -#define Led_1_status() (P3_5) -#define Led_1_write(x) (P3_5 = x) -#define Led_2_on() (P3_6 = 0) -#define Led_2_off() (P3_6 = 1) -#define Led_2_toggle() (P3_6 = ~P3_6) -#define Led_2_status() (P3_6) -#define Led_2_write(x) (P3_6 = x) -#define Led_3_on() (P3_7 = 0) -#define Led_3_off() (P3_7 = 1) -#define Led_3_toggle() (P3_7 = ~P3_7) -#define Led_3_status() (P3_7) -#define Led_3_write(x) (P3_7 = x) +#define Led_0_on() (P3_3 = 0) +#define Led_0_off() (P3_3 = 1) +#define Led_0_toggle() (P3_3 = ~P3_3) +#define Led_0_status() (P3_3) +#define Led_0_write(x) (P3_3 = x) +#define Led_1_on() (P3_5 = 0) +#define Led_1_off() (P3_5 = 1) +#define Led_1_toggle() (P3_5 = ~P3_5) +#define Led_1_status() (P3_5) +#define Led_1_write(x) (P3_5 = x) +#define Led_2_on() (P3_6 = 0) +#define Led_2_off() (P3_6 = 1) +#define Led_2_toggle() (P3_6 = ~P3_6) +#define Led_2_status() (P3_6) +#define Led_2_write(x) (P3_6 = x) +#define Led_3_on() (P3_7 = 0) +#define Led_3_off() (P3_7 = 1) +#define Led_3_toggle() (P3_7 = ~P3_7) +#define Led_3_status() (P3_7) +#define Led_3_write(x) (P3_7 = x) +#define Led_all_on() (P3 &= 0x17) +#define Led_all_off() (P3 |= ~0x17) -#define Led_all_on() (P3 &= 0x17) -#define Led_all_off() (P3 |= ~0x17) - /*C************************************************************************** * NAME: PLL_3MHz *---------------------------------------------------------------------------- * PURPOSE: -* PLLDIV value for an oscillator frequency of 3MHz +* PLLDIV value for an oscillator frequency of 3MHz *****************************************************************************/ -#define PLL_3MHz 0xF0 +#define PLL_3MHz 0xF0 /*C************************************************************************** * NAME: PLL_4MHz *---------------------------------------------------------------------------- * PURPOSE: -* PLLDIV value for an oscillator frequency of 4MHz +* PLLDIV value for an oscillator frequency of 4MHz *****************************************************************************/ -#define PLL_4MHz 0xC0 +#define PLL_4MHz 0xC0 /*C************************************************************************** * NAME: PLL_6MHz *---------------------------------------------------------------------------- -* PURPOSE: -* PLLDIV value for an oscillator frequency of 6MHz +* PURPOSE: +* PLLDIV value for an oscillator frequency of 6MHz *****************************************************************************/ -#define PLL_6MHz 0x70 +#define PLL_6MHz 0x70 /*C************************************************************************** * NAME: PLL_8MHz *---------------------------------------------------------------------------- -* PURPOSE: -* PLLDIV value for an oscillator frequency of 8MHz +* PURPOSE: +* PLLDIV value for an oscillator frequency of 8MHz *****************************************************************************/ -#define PLL_8MHz 0x50 +#define PLL_8MHz 0x50 /*C************************************************************************** * NAME: PLL_12MHz *---------------------------------------------------------------------------- -* PURPOSE: -* PLLDIV value for an oscillator frequency of 12MHz +* PURPOSE: +* PLLDIV value for an oscillator frequency of 12MHz *****************************************************************************/ -#define PLL_12MHz 0x30 +#define PLL_12MHz 0x30 /*C************************************************************************** * NAME: PLL_16MHz *---------------------------------------------------------------------------- -* PURPOSE: -* PLLDIV value for an oscillator frequency of 16MHz +* PURPOSE: +* PLLDIV value for an oscillator frequency of 16MHz *****************************************************************************/ -#define PLL_16MHz 0x20 +#define PLL_16MHz 0x20 /*C************************************************************************** * NAME: PLL_18MHz *---------------------------------------------------------------------------- -* PURPOSE: -* PLLDIV value for an oscillator frequency of 18MHz +* PURPOSE: +* PLLDIV value for an oscillator frequency of 18MHz *****************************************************************************/ -#define PLL_18MHz 0x72 +#define PLL_18MHz 0x72 /*C************************************************************************** * NAME: PLL_20MHz *---------------------------------------------------------------------------- -* PURPOSE: -* PLLDIV value for an oscillator frequency of 20MHz +* PURPOSE: +* PLLDIV value for an oscillator frequency of 20MHz *****************************************************************************/ -#define PLL_20MHz 0xB4 +#define PLL_20MHz 0xB4 /*C************************************************************************** * NAME: PLL_24MHz *---------------------------------------------------------------------------- -* PURPOSE: -* PLLDIV value for an oscillator frequency of 24MHz +* PURPOSE: +* PLLDIV value for an oscillator frequency of 24MHz *****************************************************************************/ -#define PLL_24MHz 0x10 +#define PLL_24MHz 0x10 /*C************************************************************************** * NAME: PLL_32MHz *---------------------------------------------------------------------------- -* PURPOSE: -* PLLDIV value for an oscillator frequency of 32MHz +* PURPOSE: +* PLLDIV value for an oscillator frequency of 32MHz *****************************************************************************/ -#define PLL_32MHz 0x21 +#define PLL_32MHz 0x21 /*C************************************************************************** * NAME: PLL_40MHz *---------------------------------------------------------------------------- -* PURPOSE: -* PLLDIV value for an oscillator frequency of 40MHz +* PURPOSE: +* PLLDIV value for an oscillator frequency of 40MHz *****************************************************************************/ -#define PLL_40MHz 0xB9 +#define PLL_40MHz 0xB9 /* UART */ -#define MSK_UART_MODE0 0x00 /* SCON */ -#define MSK_UART_8BIT 0x40 -#define MSK_UART_MODE1 0x40 -#define MSK_UART_MODE2 0x80 -#define MSK_UART_MODE3 0xC0 -#define MSK_UART_9BIT 0xC0 -#define MSK_UART_MULTIPROC 0x20 -#define MSK_UART_ENABLE_RX 0x10 -#define MSK_UART_TX_BIT9 0x08 -#define MSK_UART_RX_BIT9 0x04 -#define MSK_UART_TX_READY 0x02 -#define MSK_UART_RX_DONE 0x01 +#define MSK_UART_MODE0 0x00 /* SCON */ +#define MSK_UART_8BIT 0x40 +#define MSK_UART_MODE1 0x40 +#define MSK_UART_MODE2 0x80 +#define MSK_UART_MODE3 0xC0 +#define MSK_UART_9BIT 0xC0 +#define MSK_UART_MULTIPROC 0x20 +#define MSK_UART_ENABLE_RX 0x10 +#define MSK_UART_TX_BIT9 0x08 +#define MSK_UART_RX_BIT9 0x04 +#define MSK_UART_TX_READY 0x02 +#define MSK_UART_RX_DONE 0x01 -#define Uart_hw_init(config) (SCON=(config)) +#define Uart_hw_init(config) (SCON=(config)) //#define Uart_set_baudrate(bdr) defined in /lib_mcu/uart/uart_bdr.h -#define Uart_enable() (SCON|=MSK_UART_ENABLE_RX|MSK_UART_TX_READY) -#define Uart_tx_ready() ((const bit)TI) -#define Uart_set_tx_busy() (TI=0) -#define Uart_send_byte(ch) (SBUF=ch) -#define Uart_rx_ready() ((const bit)RI) -#define Uart_get_byte() ((const char)SBUF) -#define Uart_ack_rx_byte() (RI=0) +#define Uart_enable() (SCON|=MSK_UART_ENABLE_RX|MSK_UART_TX_READY) +#define Uart_tx_ready() ((const bit)TI) +#define Uart_set_tx_busy() (TI=0) +#define Uart_send_byte(ch) (SBUF=ch) +#define Uart_rx_ready() ((const bit)RI) +#define Uart_get_byte() ((const char)SBUF) +#define Uart_ack_rx_byte() (RI=0) -#endif /* _5131_DRV_H_ */ - +#endif /* _5131_DRV_H_ */ Modified: firmware/fuxusb/trunk/lib_mcu/c51_drv.h =================================================================== --- firmware/fuxusb/trunk/lib_mcu/c51_drv.h 2007-10-03 08:28:04 UTC (rev 578) +++ firmware/fuxusb/trunk/lib_mcu/c51_drv.h 2007-10-03 11:19:59 UTC (rev 579) @@ -1,10 +1,11 @@ + /*H************************************************************************** -* NAME: c51_drv.h +* NAME: c51_drv.h *---------------------------------------------------------------------------- * Copyright (c) 2004 Atmel. *---------------------------------------------------------------------------- -* RELEASE: c5131-usb-cdc-1_0_2 -* REVISION: 1.1 +* RELEASE: c5131-usb-cdc-1_0_2 +* REVISION: 1.1 *---------------------------------------------------------------------------- * PURPOSE: * This file contains the C51 driver definition @@ -15,29 +16,24 @@ /*_____ I N C L U D E S ____________________________________________________*/ - /*_____ M A C R O S ________________________________________________________*/ - /*_____ D E F I N I T I O N ________________________________________________*/ - /*_____ D E C L A R A T I O N ______________________________________________*/ -#define Set_x2_mode() (CKCON |= MSK_X2) -#define Set_x1_mode() (CKCON &= ~MSK_X2) -#define Mode_x2() ((CKCON & MSK_X2) == MSK_X2) +#define Set_x2_mode() (CKCON |= MSK_X2) +#define Set_x1_mode() (CKCON &= ~MSK_X2) +#define Mode_x2() ((CKCON & MSK_X2) == MSK_X2) -#define Set_idle_mode() (PCON |= MSK_IDLE) -#define Set_power_down_mode() (PCON |= MSK_PD) +#define Set_idle_mode() (PCON |= MSK_IDLE) +#define Set_power_down_mode() (PCON |= MSK_PD) -#define Enable_eram() (AUXR &= ~MSK_EXTRAM) -#define Disable_eram() (AUXR |= MSK_EXTRAM) -#define Set_eram_size(s) (AUXR &= ~MSK_XRS); (AUXR |= s) +#define Enable_eram() (AUXR &= ~MSK_EXTRAM) +#define Disable_eram() (AUXR |= MSK_EXTRAM) +#define Set_eram_size(s) (AUXR &= ~MSK_XRS); (AUXR |= s) -#define Enable_interrupt() (EA = 1) -#define Disable_interrupt() (EA = 0) +#define Enable_interrupt() (EA = 1) +#define Disable_interrupt() (EA = 0) - -#endif /* _C51_DRV_H_ */ - +#endif /* _C51_DRV_H_ */ Modified: firmware/fuxusb/trunk/lib_mcu/compiler.h =================================================================== --- firmware/fuxusb/trunk/lib_mcu/compiler.h 2007-10-03 08:28:04 UTC (rev 578) +++ firmware/fuxusb/trunk/lib_mcu/compiler.h 2007-10-03 11:19:59 UTC (rev 579) @@ -1,10 +1,11 @@ + /*H************************************************************************** -* NAME: compiler.h +* NAME: compiler.h *---------------------------------------------------------------------------- * Copyright (c) 2004 Atmel. *---------------------------------------------------------------------------- -* RELEASE: c5131-usb-cdc-1_0_2 -* FILE_REV: 1.2 +* RELEASE: c5131-usb-cdc-1_0_2 +* FILE_REV: 1.2 *---------------------------------------------------------------------------- * PURPOSE: * This file redefines dedicated KEIL, RAISONANCE and TASKINKG C51/C251 @@ -17,61 +18,60 @@ /*_____ I N C L U D E S ____________________________________________________*/ - /*_____ D E C L A R A T I O N S ____________________________________________*/ -typedef unsigned char Uchar; -typedef float Float16; +typedef unsigned char Uchar; +typedef float Float16; -typedef unsigned char Uint8; -typedef unsigned int Uint16; -typedef unsigned long int Uint32; +typedef unsigned char Uint8; +typedef unsigned int Uint16; +typedef unsigned long int Uint32; -typedef char Int8; -typedef int Int16; -typedef long int Int32; +typedef char Int8; +typedef int Int16; +typedef long int Int32; -typedef unsigned char Bool; -typedef unsigned char Byte; -typedef unsigned int Word; -typedef unsigned long int DWord; +typedef unsigned char Bool; +typedef unsigned char Byte; +typedef unsigned int Word; +typedef unsigned long int DWord; -typedef union +typedef union { - Uint32 l; - Uint16 w[2]; - Uint8 b[4]; + Uint32 l; + Uint16 w[2]; + Uint8 b[4]; } Union32; -typedef union +typedef union { - Uint16 w; - Uint8 b[2]; + Uint16 w; + Uint8 b[2]; } Union16; - /*_____ M A C R O S ________________________________________________________*/ /* General purpose defines */ -#define _ConstType_ code +#define _ConstType_ code + /* Constants */ -#define FALSE 0 -#define TRUE 1 -#define KO 0 -#define OK 1 -#define OFF 0 -#define ON 1 -#define CLR 0 -#define SET 1 +#define FALSE 0 +#define TRUE 1 +#define KO 0 +#define OK 1 +#define OFF 0 +#define ON 1 +#define CLR 0 +#define SET 1 /* Bit and bytes manipulations */ -#define LOW(U16) ((Uchar)U16) -#define HIGH(U16) ((Uchar)(U16>>8)) -#define TST_BIT_X(addrx,mask) (*addrx & mask) -#define SET_BIT_X(addrx,mask) (*addrx = (*addrx | mask)) -#define CLR_BIT_X(addrx,mask) (*addrx = (*addrx & ~mask)) -#define OUT_X(addrx,value) (*addrx = value) -#define IN_X(addrx) (*addrx) +#define LOW(U16) ((Uchar)U16) +#define HIGH(U16) ((Uchar)(U16>>8)) +#define TST_BIT_X(addrx,mask) (*addrx & mask) +#define SET_BIT_X(addrx,mask) (*addrx = (*addrx | mask)) +#define CLR_BIT_X(addrx,mask) (*addrx = (*addrx & ~mask)) +#define OUT_X(addrx,value) (*addrx = value) +#define IN_X(addrx) (*addrx) /* little endian conversion */ #define LE16(b) (((b & 0xFF) << 8) | ((b & 0xFF00) >> 8)) @@ -79,67 +79,63 @@ ((b & 0xFF0000) >> 8) | ((b & 0xFF000000) >> 24)) /*********************************************************** - SET_SFR_BIT macro - parameters - sfr_reg : defined value in include file for sfr register + SET_SFR_BIT macro + parameters + sfr_reg : defined value in include file for sfr register bit_pos : defined value B_XX in include file for particular - bit of sfr register - bit_val : CLR / SET + bit of sfr register + bit_val : CLR / SET ************************************************************/ #define SET_SFR_BIT(sfr_reg, bit_pos, bit_val) { sfr_reg &= ~(1<<(bit_pos)); sfr_reg |= ((bit_val)<<(bit_pos));} /*********************************************************** - TST_SFR_BIT macro - parameters - sfr_reg : defined value in include file for sfr register + TST_SFR_BIT macro + parameters + sfr_reg : defined value in include file for sfr register bit_pos : defined value B_XX in include file for particular - bit of sfr register + bit of sfr register ************************************************************/ #define TST_SFR_BIT(sfr_reg, bit_pos) ((sfr_reg & (1<<(bit_pos)))>>(bit_pos)) -#ifdef KEIL /* KEIL compiler */ +#ifdef KEIL /* KEIL compiler */ -#define Reentrant(x) x reentrant -#define Sfr(x,y) sfr x = y -#define Sfr16(x,y) sfr16 x = y -#define Sbit(x,y,z) sbit x = y ^ z -#define Interrupt(x,y) x interrupt y -#define At(x) _at_ x +#define Reentrant(x) x reentrant +#define Sfr(x,y) sfr x = y +#define Sfr16(x,y) sfr16 x = y +#define Sbit(x,y,z) sbit x = y ^ z +#define Interrupt(x,y) x interrupt y +#define At(x) _at_ x -#ifdef __C51__ /* C51 Compiler */ -#define far xdata /* far is for C251 only */ +#ifdef __C51__ /* C51 Compiler */ +#define far xdata /* far is for C251 only */ #endif -#endif /* End of KEIL */ +#endif /* End of KEIL */ +#ifdef RAISONANCE /* RAISONANCE compiler */ -#ifdef RAISONANCE /* RAISONANCE compiler */ +#define Reentrant(x) x reentrant +#define Sfr(x,y) sfr x = y +#define Sbit(x,y,z) sbit x = y ^ z +#define Interrupt(x,y) x interrupt y +#define At(x) _at_ x -#define Reentrant(x) x reentrant -#define Sfr(x,y) sfr x = y -#define Sbit(x,y,z) sbit x = y ^ z -#define Interrupt(x,y) x interrupt y -#define At(x) _at_ x - -#ifdef __C51__ /* C51 Compiler */ -#define far xdata /* far is for 251 only */ +#ifdef __C51__ /* C51 Compiler */ +#define far xdata /* far is for 251 only */ #endif -#endif /* End of RAISONANCE */ +#endif /* End of RAISONANCE */ +#ifdef TASKING /* TASKING compiler */ -#ifdef TASKING /* TASKING compiler */ +#include <keil.h> /* Include Tasking / Keil compatibility header file */ -#include <keil.h> /* Include Tasking / Keil compatibility header file */ +#define far _far +#define Reentrant(x) _reentrant x +#define Sfr(x,y) _sfrbyte x _at(y) +#define Sbit(x,y,z) _sfrbit x _atbit(y,z) +#define Interrupt(x,y) _interrupt(y) x -#define far _far -#define Reentrant(x) _reentrant x -#define Sfr(x,y) _sfrbyte x _at(y) -#define Sbit(x,y,z) _sfrbit x _atbit(y,z) -#define Interrupt(x,y) _interrupt(y) x +#endif /* End of TASKING */ -#endif /* End of TASKING */ - - #endif /* _COMPILER_H_ */ - Modified: firmware/fuxusb/trunk/lib_mcu/ext_5131.h =================================================================== --- firmware/fuxusb/trunk/lib_mcu/ext_5131.h 2007-10-03 08:28:04 UTC (rev 578) +++ firmware/fuxusb/trunk/lib_mcu/ext_5131.h 2007-10-03 11:19:59 UTC (rev 579) @@ -1,12 +1,13 @@ + /*H*************************************************************************** -* NAME: ext_5131.h +* NAME: ext_5131.h *----------------------------------------------------------------------------- -* $AUTHOR: $ -* $REVISION: 1.0 $ -* $DATE: $ +* $AUTHOR: $ +* $REVISION: 1.0 $ +* $DATE: $ *----------------------------------------------------------------------------- -* PURPOSE: This file is an extension to the reg_5131.h file. -* It defines mask for registers. +* PURPOSE: This file is an extension to the reg_5131.h file. +* It defines mask for registers. *----------------------------------------------------------------------------- * CHANGES: * @@ -17,185 +18,176 @@ /*_____ I N C L U D E S ____________________________________________________*/ - /*_____ M A C R O S ________________________________________________________*/ /* INTERRUPT NUMBER */ -#define IRQ_INT0 0 -#define IRQ_T0 1 -#define IRQ_INT1 2 -#define IRQ_T1 3 -#define IRQ_UART 4 -#define IRQ_T2 5 -#define IRQ_PCA 6 -#define IRQ_KBD 7 -#define IRQ_TWI 8 -#define IRQ_SPI 9 -#define IRQ_USB 13 +#define IRQ_INT0 0 +#define IRQ_T0 1 +#define IRQ_INT1 2 +#define IRQ_T1 3 +#define IRQ_UART 4 +#define IRQ_T2 5 +#define IRQ_PCA 6 +#define IRQ_KBD 7 +#define IRQ_TWI 8 +#define IRQ_SPI 9 +#define IRQ_USB 13 /* USB */ -#define MSK_TXCMPL 0x01 /* UEPSTAX */ -#define MSK_RXOUTB0 0x02 -#define MSK_RXOUT 0x02 -#define MSK_RXSETUP 0x04 -#define MSK_STALLED 0x08 -#define MSK_TXRDY 0x10 -#define MSK_STALLRQ 0x20 -#define MSK_RXOUTB1 0x40 -#define MSK_DIR 0x80 +#define MSK_TXCMPL 0x01 /* UEPSTAX */ +#define MSK_RXOUTB0 0x02 +#define MSK_RXOUT 0x02 +#define MSK_RXSETUP 0x04 +#define MSK_STALLED 0x08 +#define MSK_TXRDY 0x10 +#define MSK_STALLRQ 0x20 +#define MSK_RXOUTB1 0x40 +#define MSK_DIR 0x80 #define MSK_RXOUTB0B1 0x42 -#define MSK_EP_DIR 0x7F +#define MSK_EP_DIR 0x7F -#define MSK_SPINT 0x01 /* USBINT */ -#define MSK_SOFINT 0x08 -#define MSK_EORINT 0x10 -#define MSK_WUPCPU 0x20 +#define MSK_SPINT 0x01 /* USBINT */ +#define MSK_SOFINT 0x08 +#define MSK_EORINT 0x10 +#define MSK_WUPCPU 0x20 -#define MSK_ESPINT 0x01 /* USBIEN */ -#define MSK_ESOFINT 0x08 -#define MSK_EEORINT 0x10 -#define MSK_EWUPCPU 0x20 +#define MSK_ESPINT 0x01 /* USBIEN */ +#define MSK_ESOFINT 0x08 +#define MSK_EEORINT 0x10 +#define MSK_EWUPCPU 0x20 -#define MSK_USBE 0x80 /* USBCON */ -#define MSK_SUSPCLK 0x40 -#define MSK_SDRMWUP 0x20 -#define MSK_DETACH 0x10 -#define MSK_UPRSM 0x08 -#define MSK_RMWUPE 0x04 -#define MSK_CONFG 0x02 -#define MSK_FADDEN 0x01 +#define MSK_USBE 0x80 /* USBCON */ +#define MSK_SUSPCLK 0x40 +#define MSK_SDRMWUP 0x20 +#define MSK_DETACH 0x10 +#define MSK_UPRSM 0x08 +#define MSK_RMWUPE 0x04 +#define MSK_CONFG 0x02 +#define MSK_FADDEN 0x01 -#define MSK_FEN 0x80 /* USBADDR */ +#define MSK_FEN 0x80 /* USBADDR */ -#define MSK_EPEN 0x80 /* UEPCONX */ -#define MSK_DTGL 0x08 -#define MSK_EPDIR 0x04 -#define MSK_EPTYPE1 0x02 -#define MSK_EPTYPE0 0x01 +#define MSK_EPEN 0x80 /* UEPCONX */ +#define MSK_DTGL 0x08 +#define MSK_EPDIR 0x04 +#define MSK_EPTYPE1 0x02 +#define MSK_EPTYPE0 0x01 -#define MSK_EP6RST 0x40 /* UEPRST */ -#define MSK_EP5RST 0x20 -#define MSK_EP4RST 0x10 -#define MSK_EP3RST 0x08 -#define MSK_EP2RST 0x04 -#define MSK_EP1RST 0x02 -#define MSK_EP0RST 0x01 +#define MSK_EP6RST 0x40 /* UEPRST */ +#define MSK_EP5RST 0x20 +#define MSK_EP4RST 0x10 +#define MSK_EP3RST 0x08 +#define MSK_EP2RST 0x04 +#define MSK_EP1RST 0x02 +#define MSK_EP0RST 0x01 -#define MSK_EP6INTE 0x40 /* UEPIEN */ -#define MSK_EP5INTE 0x20 -#define MSK_EP4INTE 0x10 -#define MSK_EP3INTE 0x08 -#define MSK_EP2INTE 0x04 -#define MSK_EP1INTE 0x02 -#define MSK_EP0INTE 0x01 +#define MSK_EP6INTE 0x40 /* UEPIEN */ +#define MSK_EP5INTE 0x20 +#define MSK_EP4INTE 0x10 +#define MSK_EP3INTE 0x08 +#define MSK_EP2INTE 0x04 +#define MSK_EP1INTE 0x02 +#define MSK_EP0INTE 0x01 -#define MSK_CRCOK 0x20 /* UFNUMH */ -#define MSK_CRCERR 0x10 +#define MSK_CRCOK 0x20 /* UFNUMH */ +#define MSK_CRCERR 0x10 /* SYSTEM MANAGEMENT */ -#define MSK_SMOD1 0x80 /* PCON */ -#define MSK_SMOD0 0x40 -#define MSK_POF 0x10 -#define MSK_GF1 0x08 -#define MSK_GF0 0x04 -#define MSK_PD 0x02 -#define MSK_IDLE 0x01 +#define MSK_SMOD1 0x80 /* PCON */ +#define MSK_SMOD0 0x40 +#define MSK_POF 0x10 +#define MSK_GF1 0x08 +#define MSK_GF0 0x04 +#define MSK_PD 0x02 +#define MSK_IDLE 0x01 -#define MSK_DPU 0x80 /* AUXR0 */ -#define MSK_M0 0x20 -#define MSK_DPHDIS 0x10 -#define MSK_XRS 0x0C -#define MSK_EXTRAM 0x02 -#define MSK_AO 0x01 +#define MSK_DPU 0x80 /* AUXR0 */ +#define MSK_M0 0x20 +#define MSK_DPHDIS 0x10 +#define MSK_XRS 0x0C +#define MSK_EXTRAM 0x02 +#define MSK_AO 0x01 -#define MSK_ENBOOT 0x20 /* AUXR1 */ -#define MSK_GF3 0x08 -#define MSK_DPS 0x01 +#define MSK_ENBOOT 0x20 /* AUXR1 */ +#define MSK_GF3 0x08 +#define MSK_DPS 0x01 - /* PLL & CLOCK */ -#define MSK_TWIX2 0x80 /* CKCON0 */ -#define MSK_WDX2 0x40 -#define MSK_PCAX2 0x20 -#define MSK_SIX2 0x10 -#define MSK_T2X2 0x08 -#define MSK_T1X2 0x04 -#define MSK_T0X2 0x02 -#define MSK_X2 0x01 +#define MSK_TWIX2 0x80 /* CKCON0 */ +#define MSK_WDX2 0x40 +#define MSK_PCAX2 0x20 +#define MSK_SIX2 0x10 +#define MSK_T2X2 0x08 +#define MSK_T1X2 0x04 +#define MSK_T0X2 0x02 +#define MSK_X2 0x01 -#define MSK_SPIX2 0x01 /* CKCON1 */ +#define MSK_SPIX2 0x01 /* CKCON1 */ -#define MSK_PLOCK 0x01 /* PLLCON */ -#define MSK_PLLEN 0x02 -#define MSK_EXT48 0x04 +#define MSK_PLOCK 0x01 /* PLLCON */ +#define MSK_PLLEN 0x02 +#define MSK_EXT48 0x04 -#define MSK_R 0xF0 /* PLLDIV */ -#define MSK_N 0x0F +#define MSK_R 0xF0 /* PLLDIV */ +#define MSK_N 0x0F - /* INTERRUPT */ -#define MSK_EC 0x40 /* IEN0 */ -#define MSK_ET2 0x20 -#define MSK_ES 0x10 -#define MSK_ET1 0x08 -#define MSK_EX1 0x04 -#define MSK_ET0 0x02 -#define MSK_EX0 0x01 +#define MSK_EC 0x40 /* IEN0 */ +#define MSK_ET2 0x20 +#define MSK_ES 0x10 +#define MSK_ET1 0x08 +#define MSK_EX1 0x04 +#define MSK_ET0 0x02 +#define MSK_EX0 0x01 -#define MSK_EUSB 0x40 /* IEN1 */ -#define MSK_ESPI 0x04 -#define MSK_ETWI 0x02 -#define MSK_EKB 0x01 +#define MSK_EUSB 0x40 /* IEN1 */ +#define MSK_ESPI 0x04 +#define MSK_ETWI 0x02 +#define MSK_EKB 0x01 - /* TIMERS */ -#define MSK_GATE1 0x80 /* TMOD */ -#define MSK_C_T1 0x40 -#define MSK_MO1 0x30 -#define MSK_GATE0 0x08 -#define MSK_C_T0 0x04 -#define MSK_MO0 0x03 +#define MSK_GATE1 0x80 /* TMOD */ +#define MSK_C_T1 0x40 +#define MSK_MO1 0x30 +#define MSK_GATE0 0x08 +#define MSK_C_T0 0x04 +#define MSK_MO0 0x03 - /* WATCHDOG */ -#define MSK_WTO 0x07 /* WDTPRG*/ +#define MSK_WTO 0x07 /* WDTPRG */ /* SPI CONTROLLER */ -#define MSK_SPR 0x83 /* SPCON */ -#define MSK_SPEN 0x40 -#define MSK_SSDIS 0x20 -#define MSK_MSTR 0x10 -#define MSK_MODE 0x0C -#define MSK_CPOL 0x08 -#define MSK_CPHA 0x04 +#define MSK_SPR 0x83 /* SPCON */ +#define MSK_SPEN 0x40 +#define MSK_SSDIS 0x20 +#define MSK_MSTR 0x10 +#define MSK_MODE 0x0C +#define MSK_CPOL 0x08 +#define MSK_CPHA 0x04 -#define MSK_SPIF 0x80 /* SPSTA */ -#define MSK_WCOL 0x40 -#define MSK_MODF 0x10 +#define MSK_SPIF 0x80 /* SPSTA */ +#define MSK_WCOL 0x40 +#define MSK_MODF 0x10 - /* TWI CONTROLLER */ -#define MSK_SSCR 0x83 /* SSCON */ -#define MSK_SSPE 0x40 -#define MSK_SSSTA 0x20 -#define MSK_SSSTO 0x10 -#define MSK_SSSI 0x08 -#define MSK_SSAA 0x04 +#define MSK_SSCR 0x83 /* SSCON */ +#define MSK_SSPE 0x40 +#define MSK_SSSTA 0x20 +#define MSK_SSSTO 0x10 +#define MSK_SSSI 0x08 +#define MSK_SSAA 0x04 - /* FLASH */ -#define MSK_FCON_FBUSY 0x01 +#define MSK_FCON_FBUSY 0x01 - - -#endif /* _EXT5131_H_ */ +#endif /* _EXT5131_H_ */ Modified: firmware/fuxusb/trunk/lib_mcu/fa-usb/flash_api.c =================================================================== --- firmware/fuxusb/trunk/lib_mcu/fa-usb/flash_api.c 2007-10-03 08:28:04 UTC (rev 578) +++ firmware/fuxusb/trunk/lib_mcu/fa-usb/flash_api.c 2007-10-03 11:19:59 UTC (rev 579) @@ -1,12 +1,13 @@ + /*C************************************************************************** -* NAME: flash_api.c +* NAME: flash_api.c *---------------------------------------------------------------------------- * Copyright (c) 2003 Atmel. *---------------------------------------------------------------------------- -* RELEASE: c5131-usb-flash-api-1_0_5 -* REVISION: 1.3 +* RELEASE: c5131-usb-flash-api-1_0_5 +* REVISION: 1.3 *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: * This file contains whole of functions to access AT89C5131 Flash and EEPROM. *****************************************************************************/ @@ -19,325 +20,322 @@ /*_____ D E F I N I T I O N ________________________________________________*/ -Uchar data api_command _at_ 0x1C; -Uchar data api_value _at_ 0x1D; -Uchar data api_dpl _at_ 0x1F; -Uchar data api_dph _at_ 0x1E; +Uchar data api_command _at_ 0x1C; +Uchar data api_value _at_ 0x1D; +Uchar data api_dpl _at_ 0x1F; +Uchar data api_dph _at_ 0x1E; - -#define MSK_AUXR1_ENBOOT 0x20 -#define MAP_BOOT AUXR1 |= MSK_AUXR1_ENBOOT; -#define UNMAP_BOOT AUXR1 &= ~MSK_AUXR1_ENBOOT; +#define MSK_AUXR1_ENBOOT 0x20 +#define MAP_BOOT AUXR1 |= MSK_AUXR1_ENBOOT; +#define UNMAP_BOOT AUXR1 &= ~MSK_AUXR1_ENBOOT; -#define __API_FLASH_ENTRY_POINT (*((const void(code*)(void)) 0xFFC0 )) +#define __API_FLASH_ENTRY_POINT (*((const void(code*)(void)) 0xFFC0 )) #define __API_FLASH_ENTRY_POINT_PE (*((const void(code*)(void)) 0xFFF3 )) -#define __API_JMP_ISP_START (*((const void(code*)(void)) 0xFF00 )) -#define __API_JMP_BOOTLOADER (*((const void(code*)(void)) 0xF400 )) +#define __API_JMP_ISP_START (*((const void(code*)(void)) 0xFF00 )) +#define __API_JMP_BOOTLOADER (*((const void(code*)(void)) 0xF400 )) /*_____ D E C L A R A T I O N ______________________________________________*/ - /*F************************************************************************** -* NAME: __api_rd_generic +* NAME: __api_rd_generic *---------------------------------------------------------------------------- * PARAMS: -* Uchar command: api_command to call -* Uchar dpl : api_dpl -* return: +* Uchar command: api_command to call +* Uchar dpl : api_dpl +* return: * Uchar : read value *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: * This function allows to read xaf and special area *---------------------------------------------------------------------------- * EXAMPLE: *---------------------------------------------------------------------------- -* NOTE: +* NOTE: *---------------------------------------------------------------------------- -* REQUIREMENTS: +* REQUIREMENTS: *****************************************************************************/ -Uchar __api_rd_generic (Uchar command, Uchar dpl) +Uchar __api_rd_generic(Uchar command, Uchar dpl) { - api_command = command; - api_dpl = dpl; - MAP_BOOT; - __API_FLASH_ENTRY_POINT(); - UNMAP_BOOT; + api_command = command; + api_dpl = dpl; + MAP_BOOT; + __API_FLASH_ENTRY_POINT(); + UNMAP_BOOT; - return(api_value); + return (api_value); } /*F************************************************************************** -* NAME: __api_wr_generic +* NAME: __api_wr_generic *---------------------------------------------------------------------------- * PARAMS: -* Uchar command: api_command to call -* Uchar value : api_value -* Uchar dpl : api_dpl -* return: +* Uchar command: api_command to call +* Uchar value : api_value +* Uchar dpl : api_dpl +* return: * Uchar return: command status (1 - ok) *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: * This function allows to write in xaf *---------------------------------------------------------------------------- * EXAMPLE: *---------------------------------------------------------------------------- -* NOTE: +* NOTE: *---------------------------------------------------------------------------- -* REQUIREMENTS: +* REQUIREMENTS: *****************************************************************************/ -Uchar __api_wr_generic (Uchar command, Uchar value, Uchar dpl) +Uchar __api_wr_generic(Uchar command, Uchar value, Uchar dpl) { - bit ea_save; + bit ea_save; - ea_save = EA; - EA = 0; - api_command = command; - api_dpl = dpl; - api_value = value; - MAP_BOOT; - __API_FLASH_ENTRY_POINT(); - UNMAP_BOOT; - EA = ea_save; // restore interrupt state - return(1); + ea_save = EA; + EA = 0; + api_command = command; + api_dpl = dpl; + api_value = value; + MAP_BOOT; + __API_FLASH_ENTRY_POINT(); + UNMAP_BOOT; + EA = ea_save; // restore interrupt state + return (1); } /*F************************************************************************** -* NAME: __api_rd_code_byte +* NAME: __api_rd_code_byte *---------------------------------------------------------------------------- * PARAMS: -* Uint16 address : address in flash memory to read -* return: +* Uint16 address : address in flash memory to read +* return: * Uchar device : read value *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: * This function allows to read a flash memory byte. *---------------------------------------------------------------------------- * EXAMPLE: *---------------------------------------------------------------------------- * NOTE: -* To use this function the constante __API_RD_CODE_BYTE must be define in +* To use this function the constante __API_RD_CODE_BYTE must be define in * C header file flash_api.h. *---------------------------------------------------------------------------- -* REQUIREMENTS: +* REQUIREMENTS: *****************************************************************************/ #ifdef __API_RD_CODE_BYTE -Uchar __api_rd_code_byte (Uchar code * pt_address) +Uchar __api_rd_code_byte(Uchar code * pt_address) { - return(*pt_address); + return (*pt_address); } #endif /*F************************************************************************** -* NAME: __api_wr_code_byte +* NAME: __api_wr_code_byte *---------------------------------------------------------------------------- * PARAMS: * Uint16 address : address to program -* Uchar value : data to write -* return: -* Uchar return : -* return = 0x00 -> pass -* return != 0x00 -> fail +* Uchar value : data to write +* return: +* Uchar return : +* return = 0x00 -> pass +* return != 0x00 -> fail *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: * This function allows to program data byte in Flash memory. *---------------------------------------------------------------------------- * EXAMPLE: *---------------------------------------------------------------------------- * NOTE: -* To use this function the constante __API_WR_CODE_BYTE must be define in +* To use this function the constante __API_WR_CODE_BYTE must be define in * C header file flash_api.h. *---------------------------------------------------------------------------- -* REQUIREMENTS: +* REQUIREMENTS: *****************************************************************************/ #ifdef __API_WR_CODE_BYTE -Uchar __api_wr_code_byte (Uchar xdata * pt_address, Uchar value) +Uchar __api_wr_code_byte(Uchar xdata * pt_address, Uchar value) { - bit ea_save; + bit ea_save; - ea_save = EA; - EA = 0; - api_command = _COMMAND_WR_CODE_BYTE; - FCON = 0x08; + ea_save = EA; + EA = 0; + api_command = _COMMAND_WR_CODE_BYTE; + FCON = 0x08; - *pt_address = value; + *pt_address = value; - MAP_BOOT; - __API_FLASH_ENTRY_POINT_PE(); - UNMAP_BOOT; - EA = ea_save; // restore interrupt state + MAP_BOOT; + __API_FLASH_ENTRY_POINT_PE(); + UNMAP_BOOT; + EA = ea_save; // restore interrupt state - return(api_value); + return (api_value); } #endif - /*F************************************************************************** -* NAME: __api_wr_code_page +* NAME: __api_wr_code_page *---------------------------------------------------------------------------- * PARAMS: * Uint16 add_flash : address of the first byte to program in the Flash -* Uint16 add_xram : address in XRAM of the first data to program +* Uint16 add_xram : address in XRAM of the first data to program * Uchar nb_data : number of bytes to program -* return: -* Uchar return : -* return = 0x00 -> pass -* return != 0x00 -> fail +* return: +* Uchar return : +* return = 0x00 -> pass +* return != 0x00 -> fail *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: * This function allows to program until 128 Datas in Flash memory. * Number of bytes to program is limited such as the Flash write remains in a -* single 128 bytes page. +* single 128 bytes page. *---------------------------------------------------------------------------- * EXAMPLE: *---------------------------------------------------------------------------- * NOTE: -* To use this function the constante __API_WR_CODE_PAGE must be define in +* To use this function the constante __API_WR_CODE_PAGE must be define in * C header file flash_api.h. -* This function used Dual Data Pointer DPTR0&1. At the end of this function +* This function used Dual Data Pointer DPTR0&1. At the end of this function * DPTR = DPTR0. *---------------------------------------------------------------------------- -* REQUIREMENTS: +* REQUIREMENTS: *****************************************************************************/ #ifdef __API_WR_CODE_PAGE -Uchar __api_wr_code_page (Uchar xdata * pt_code, Uchar xdata * pt_xram, Uchar nb_data) +Uchar __api_wr_code_page(Uchar xdata *pt_code, Uchar xdata *pt_xram, + Uchar nb_data) { - Uchar data i, temp, temp_nb_data; - bit ea_save; - Uint16 data add_pt_code, add_pt_xram; + Uchar data i, temp, temp_nb_data; + bit ea_save; + Uint16 data add_pt_code, add_pt_xram; - add_pt_xram = pt_xram; - add_pt_code = pt_code; - temp_nb_data = nb_data; - ea_save = EA; - EA = 0; - api_command = _COMMAND_WR_CODE_BYTE; - for (i=0 ; i< temp_nb_data; i++,add_pt_xram++,add_pt_code++) - { - temp = *(Uchar xdata *)add_pt_xram; + add_pt_xram = pt_xram; + add_pt_code = pt_code; + temp_nb_data = nb_data; + ea_save = EA; + EA = 0; + api_command = _COMMAND_WR_CODE_BYTE; + for (i = 0; i < temp_nb_data; i++, add_pt_xram++, add_pt_code++) + { + temp = *(Uchar xdata *) add_pt_xram; FCON = 0x08; - *(Uchar xdata *)add_pt_code = temp; + *(Uchar xdata *) add_pt_code = temp; FCON = 0x00; - } + } - MAP_BOOT; - __API_FLASH_ENTRY_POINT_PE(); - UNMAP_BOOT; - EA = ea_save; // restore interrupt state - - return(api_value); + MAP_BOOT; + __API_FLASH_ENTRY_POINT_PE(); + UNMAP_BOOT; + EA = ea_save; // restore interrupt state + + return (api_value); } #endif /*F************************************************************************** -* NAME: __api_wr_code_page_fix +* NAME: __api_wr_code_page_fix *---------------------------------------------------------------------------- * PARAMS: * Uint16 add_flash : address of the first byte to program in the Flash -* Uint16 add_xram : address in XRAM of the first data to program +* Uint16 add_xram : address in XRAM of the first data to program * Uchar nb_data : number of bytes to program -* return: -* Uchar return : -* return = 0x00 -> pass -* return != 0x00 -> fail +* return: +* Uchar return : +* return = 0x00 -> pass +* return != 0x00 -> fail *---------------------------------------------------------------------------- -* PURPOSE: +* PURPOSE: * This function allows to program until 128 Datas in Flash memory. * Number of bytes to program is limited such as the Flash write remains in a -* single 128 bytes page. +* single 128 bytes page. *---------------------------------------------------------------------------- * EXAMPLE: *---------------------------------------------------------------------------- * NOTE: -* To use this function the constante __API_WR_CODE_PAGE must be define in +* To use this function the constante __API_WR_CODE_PAGE must be define in * C header file flash_api.h. -* This function used Dual Data Pointer DPTR0&1. At the end of this function +* This function used Dual Data Pointer DPTR0&1. At the end of this function * DPTR = DPTR0. *---------------------------------------------------------------------------- -* REQUIREMENTS: +* REQUIREMENTS: *****************************************************************************/ #ifdef __API_WR_CODE_PAGE_FIX -Uchar __api_wr_code_page_fix (Uchar xdata * pt_code, Uchar xdata * pt_xram, Uchar nb_data) +Uchar __api_wr_code_page_fix(Uchar xdata *pt_code, Uchar xdata *pt_xram, + Uchar nb_data) { - bit ea_save; - Uint16 add_xram; - data Uint16 add_code; + bit ea_save; + Uint16 add_xram; + data Uint16 add_code; + add_xram = DPTR; // save the DPTR + add_code = pt_code; + ea_save = EA; + EA = 0; + add_xram = pt_xram; + api_command = 0x01; + api_value = nb_data; + api_dpl = LOW(add_xram); + api_dph = ((Uchar) ((add_xram) >> 8)); + AUXR1++; +// add_xram = DPTR; // save the DPTR +// DPTR = pt_code; + DPTR = add_code; + AUXR1++; + MAP_BOOT; + __API_FLASH_ENTRY_POINT(); + UNMAP_BOOT; - add_xram = DPTR; // save the DPTR - add_code = pt_code; - ea_save = EA; - EA = 0; - add_xram = pt_xram; - api_command =0x01; - api_value = nb_data; - api_dpl = LOW(add_xram); - api_dph = ((Uchar)((add_xram)>>8)); - AUXR1++; -// add_xram = DPTR; // save the DPTR -// DPTR = pt_code; - DPTR = add_code; - AUXR1++; - MAP_BOOT; - __API_FLASH_ENTRY_POINT(); - UNMAP_BOOT; + AUXR1++; + DPTR = add_xram; // restore the DPTR + AUXR1++; + EA = ea_save; // restore interrupt state - AUXR1++; - DPTR = add_xram; // restore the D... [truncated message content] |