- Corrected whitespace formatting with Astyle tool.
git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@132 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
parent
efbab9c73d
commit
90b766c778
|
@ -0,0 +1,20 @@
|
|||
@echo off
|
||||
rem Configuration file for Astyle. Can be downloaded from: https://sourceforge.net/projects/astyle/?source=typ_redirect
|
||||
rem Example usage: C:\Work\software\OpenBLT\Target\Source>..\..\Doc\astyle.bat *.c *.h
|
||||
set ASTYLE_BIN="C:\AStyle\bin"
|
||||
set ASTYLE_CODESTYLE_PARAMS=--mode=c --style=allman --indent=spaces=2 --indent-switches --pad-header --unpad-paren --lineend=windows --add-brackets --align-pointer=name
|
||||
set ASTYLE_EXECUTION_PARAMS=--suffix=none --formatted --ignore-exclude-errors-x --recursive
|
||||
echo.
|
||||
echo ------------------ prepare astyle ---------------------------------------------
|
||||
echo.
|
||||
%ASTYLE_BIN%\AStyle.exe --version
|
||||
echo style params: %ASTYLE_CODESTYLE_PARAMS%
|
||||
echo exec params : %ASTYLE_EXECUTION_PARAMS%
|
||||
echo user params : %*
|
||||
echo target dir : %CD%
|
||||
echo.
|
||||
echo ------------------ astyle execution -------------------------------------------
|
||||
echo.
|
||||
%ASTYLE_BIN%\AStyle.exe %ASTYLE_CODESTYLE_PARAMS% %ASTYLE_EXECUTION_PARAMS% %*
|
||||
echo.
|
||||
echo ------------------ astyle done ------------------------------------------------
|
|
@ -92,7 +92,7 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
blt_addr base_addr; /**< Base address for the flash operation.*/
|
||||
blt_int8u data[FLASH_WRITE_BLOCK_SIZE] __attribute__ ((aligned (4))); /**< Data array. */
|
||||
blt_int8u data[FLASH_WRITE_BLOCK_SIZE] __attribute__((aligned(4))); /**< Data array. */
|
||||
} tFlashBlockInfo;
|
||||
|
||||
|
||||
|
@ -188,7 +188,7 @@ static const tFlashSector flashLayout[] =
|
|||
* harvested, ideally until there is enough to program an entire flash block,
|
||||
* before the flash device is actually operated on.
|
||||
*/
|
||||
static tFlashBlockInfo blockInfo;
|
||||
static tFlashBlockInfo blockInfo;
|
||||
|
||||
/** \brief Local variable with information about the flash boot block.
|
||||
* \details The first block of the user program holds the vector table, which on the
|
||||
|
@ -241,8 +241,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
|
|||
blt_addr base_addr;
|
||||
|
||||
/* make sure the addresses are within the flash device */
|
||||
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
|
||||
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
|
|||
first_sector = FlashGetSector(addr);
|
||||
last_sector = FlashGetSector(addr+len-1);
|
||||
/* check them */
|
||||
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
|
||||
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -327,19 +327,19 @@ blt_bool FlashWriteChecksum(void)
|
|||
/* compute the checksum. note that the user program's vectors are not yet written
|
||||
* to flash but are present in the bootblock data structure at this point.
|
||||
*/
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x00]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x04]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x08]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x0C]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x10]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x18]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x1C]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x00]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x04]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x08]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x0C]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x10]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x18]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x1C]));
|
||||
signature_checksum = ~signature_checksum; /* one's complement */
|
||||
signature_checksum += 1; /* two's complement */
|
||||
|
||||
/* write the checksum */
|
||||
return FlashWrite(flashLayout[0].sector_start+0x14, sizeof(blt_addr),
|
||||
(blt_int8u*)&signature_checksum);
|
||||
(blt_int8u *)&signature_checksum);
|
||||
} /*** end of FlashWriteChecksum ***/
|
||||
|
||||
|
||||
|
@ -354,14 +354,14 @@ blt_bool FlashVerifyChecksum(void)
|
|||
blt_int32u signature_checksum = 0;
|
||||
|
||||
/* verify the checksum based on how it was written by CpuWriteChecksum() */
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x04));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x08));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x0C));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x10));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x14));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x18));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x1C));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x04));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x08));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x1C));
|
||||
|
||||
/* sum should add up to an unsigned 32-bit value of 0 */
|
||||
if (signature_checksum == 0)
|
||||
|
@ -652,8 +652,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
if ( (first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
|
||||
if ((first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -716,9 +716,9 @@ static blt_int8u FlashGetSector(blt_addr address)
|
|||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* is the address in this sector? */
|
||||
if ( (address >= flashLayout[sectorIdx].sector_start) && \
|
||||
if ((address >= flashLayout[sectorIdx].sector_start) && \
|
||||
(address < (flashLayout[sectorIdx].sector_start + \
|
||||
flashLayout[sectorIdx].sector_size)) )
|
||||
flashLayout[sectorIdx].sector_size)))
|
||||
{
|
||||
/* return the sector number */
|
||||
return flashLayout[sectorIdx].sector_num;
|
||||
|
|
|
@ -92,7 +92,7 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
blt_addr base_addr; /**< Base address for the flash operation.*/
|
||||
blt_int8u data[FLASH_WRITE_BLOCK_SIZE] __attribute__ ((aligned (4))); /**< Data array. */
|
||||
blt_int8u data[FLASH_WRITE_BLOCK_SIZE] __attribute__((aligned(4))); /**< Data array. */
|
||||
} tFlashBlockInfo;
|
||||
|
||||
|
||||
|
@ -188,7 +188,7 @@ static const tFlashSector flashLayout[] =
|
|||
* harvested, ideally until there is enough to program an entire flash block,
|
||||
* before the flash device is actually operated on.
|
||||
*/
|
||||
static tFlashBlockInfo blockInfo;
|
||||
static tFlashBlockInfo blockInfo;
|
||||
|
||||
/** \brief Local variable with information about the flash boot block.
|
||||
* \details The first block of the user program holds the vector table, which on the
|
||||
|
@ -241,8 +241,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
|
|||
blt_addr base_addr;
|
||||
|
||||
/* make sure the addresses are within the flash device */
|
||||
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
|
||||
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
|
|||
first_sector = FlashGetSector(addr);
|
||||
last_sector = FlashGetSector(addr+len-1);
|
||||
/* check them */
|
||||
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
|
||||
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -327,19 +327,19 @@ blt_bool FlashWriteChecksum(void)
|
|||
/* compute the checksum. note that the user program's vectors are not yet written
|
||||
* to flash but are present in the bootblock data structure at this point.
|
||||
*/
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x00]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x04]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x08]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x0C]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x10]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x18]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x1C]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x00]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x04]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x08]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x0C]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x10]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x18]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x1C]));
|
||||
signature_checksum = ~signature_checksum; /* one's complement */
|
||||
signature_checksum += 1; /* two's complement */
|
||||
|
||||
/* write the checksum */
|
||||
return FlashWrite(flashLayout[0].sector_start+0x14, sizeof(blt_addr),
|
||||
(blt_int8u*)&signature_checksum);
|
||||
(blt_int8u *)&signature_checksum);
|
||||
} /*** end of FlashWriteChecksum ***/
|
||||
|
||||
|
||||
|
@ -354,14 +354,14 @@ blt_bool FlashVerifyChecksum(void)
|
|||
blt_int32u signature_checksum = 0;
|
||||
|
||||
/* verify the checksum based on how it was written by CpuWriteChecksum() */
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x04));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x08));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x0C));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x10));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x14));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x18));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x1C));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x04));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x08));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x1C));
|
||||
|
||||
/* sum should add up to an unsigned 32-bit value of 0 */
|
||||
if (signature_checksum == 0)
|
||||
|
@ -652,8 +652,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
if ( (first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
|
||||
if ((first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -716,9 +716,9 @@ static blt_int8u FlashGetSector(blt_addr address)
|
|||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* is the address in this sector? */
|
||||
if ( (address >= flashLayout[sectorIdx].sector_start) && \
|
||||
if ((address >= flashLayout[sectorIdx].sector_start) && \
|
||||
(address < (flashLayout[sectorIdx].sector_start + \
|
||||
flashLayout[sectorIdx].sector_size)) )
|
||||
flashLayout[sectorIdx].sector_size)))
|
||||
{
|
||||
/* return the sector number */
|
||||
return flashLayout[sectorIdx].sector_num;
|
||||
|
|
|
@ -41,9 +41,9 @@
|
|||
/****************************************************************************************
|
||||
* Function prototypes
|
||||
****************************************************************************************/
|
||||
void __attribute__ ((interrupt("FIQ"))) FIQ_ISR(void);
|
||||
void __attribute__ ((interrupt("IRQ"))) IRQ_ISR(void);
|
||||
void __attribute__ ((interrupt("UNDEF"))) UNDEF_ISR(void);
|
||||
void __attribute__((interrupt("FIQ"))) FIQ_ISR(void);
|
||||
void __attribute__((interrupt("IRQ"))) IRQ_ISR(void);
|
||||
void __attribute__((interrupt("UNDEF"))) UNDEF_ISR(void);
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
|
|
|
@ -111,7 +111,8 @@ typedef struct t_can_bus_timing
|
|||
* a sample point between 68..78%.
|
||||
*/
|
||||
static const tCanBusTiming canTiming[] =
|
||||
{ /* TQ | TSEG1 | TSEG2 | SP */
|
||||
{
|
||||
/* TQ | TSEG1 | TSEG2 | SP */
|
||||
/* ------------------------- */
|
||||
{ 5, 2 }, /* 8 | 5 | 2 | 75% */
|
||||
{ 6, 2 }, /* 9 | 6 | 2 | 78% */
|
||||
|
@ -157,7 +158,7 @@ static blt_bool CanGetSpeedConfig(blt_int16u baud, blt_int32u *btr)
|
|||
prescaler = BOOT_CPU_SYSTEM_SPEED_KHZ/(baud*(canTiming[cnt].tseg1+canTiming[cnt].tseg2+1));
|
||||
|
||||
/* make sure the prescaler is valid */
|
||||
if ( (prescaler > 0) && (prescaler <= 1024) )
|
||||
if ((prescaler > 0) && (prescaler <= 1024))
|
||||
{
|
||||
/* store the prescaler and bustiming register value */
|
||||
*btr = prescaler - 1;
|
||||
|
|
|
@ -85,18 +85,18 @@ void CpuStartUserProgram(void)
|
|||
/* not a valid user program so it cannot be started */
|
||||
return;
|
||||
}
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
/* invoke callback */
|
||||
if (CpuUserProgramStartHook() == BLT_FALSE)
|
||||
{
|
||||
/* callback requests the user program to not be started */
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
/* release the communication interface */
|
||||
ComFree();
|
||||
#endif
|
||||
#endif
|
||||
/* reset the timer */
|
||||
TimerReset();
|
||||
/* copy the user program's interrupt vector table to RAM */
|
||||
|
@ -107,7 +107,7 @@ void CpuStartUserProgram(void)
|
|||
MEMMAP = 0x02;
|
||||
|
||||
/* set the address where the bootloader needs to jump to */
|
||||
pProgResetHandler = (void*)CPU_RAM_VECTORS_START_ADDR;
|
||||
pProgResetHandler = (void *)CPU_RAM_VECTORS_START_ADDR;
|
||||
|
||||
/* start the user program by activating its reset interrupt service routine */
|
||||
pProgResetHandler();
|
||||
|
@ -131,7 +131,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
|
|||
to = (blt_int8u *)dest;
|
||||
|
||||
/* copy all bytes from source address to destination address */
|
||||
while(len-- > 0)
|
||||
while (len-- > 0)
|
||||
{
|
||||
/* store byte value from source to destination */
|
||||
*to++ = *from++;
|
||||
|
|
|
@ -242,7 +242,7 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
static blt_bool UartReceiveByte(blt_int8u *data)
|
||||
{
|
||||
/* check if a new byte was received by means of the RDR-bit */
|
||||
if((U0LSR & UART_RDR) != 0)
|
||||
if ((U0LSR & UART_RDR) != 0)
|
||||
{
|
||||
/* store the received byte */
|
||||
data[0] = U0RBR;
|
||||
|
@ -271,7 +271,7 @@ static blt_bool UartTransmitByte(blt_int8u data)
|
|||
/* write byte to transmit holding register */
|
||||
U0THR = data;
|
||||
/* wait for tx holding register to be empty */
|
||||
while((U0LSR & UART_THRE) == 0)
|
||||
while ((U0LSR & UART_THRE) == 0)
|
||||
{
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
|
|
|
@ -70,13 +70,13 @@ typedef union
|
|||
{
|
||||
void (*func)(void); /**< for ISR function pointers */
|
||||
blt_int32u ptr; /**< for stack pointer entry */
|
||||
}tIsrFunc;
|
||||
} tIsrFunc;
|
||||
|
||||
/** \brief Interrupt vector table. */
|
||||
__attribute__ ((section(".vectors")))
|
||||
__attribute__((section(".vectors")))
|
||||
const tIsrFunc _vectors[] =
|
||||
{
|
||||
{ .ptr = (blt_int32u)&__stack_end__ }, /* the initial stack pointer */
|
||||
{ .ptr = (blt_int32u) &__stack_end__ }, /* the initial stack pointer */
|
||||
reset_handler, /* the reset handler */
|
||||
UnusedISR, /* NMI Handler */
|
||||
UnusedISR, /* Hard Fault Handler */
|
||||
|
|
|
@ -70,7 +70,7 @@ void reset_handler(void)
|
|||
__asm(" cpsid i");
|
||||
/* copy the data segment initializers from flash to SRAM */
|
||||
pSrc = &_etext;
|
||||
for(pDest = &_data; pDest < &_edata; )
|
||||
for (pDest = &_data; pDest < &_edata;)
|
||||
{
|
||||
*pDest++ = *pSrc++;
|
||||
}
|
||||
|
|
|
@ -64,13 +64,13 @@ typedef union
|
|||
{
|
||||
void (*func)(void); /**< for ISR function pointers */
|
||||
blt_int32u ptr; /**< for stack pointer entry */
|
||||
}tIsrFunc;
|
||||
} tIsrFunc;
|
||||
|
||||
/** \brief Interrupt vector table. */
|
||||
__attribute__ ((section(".isr_vector")))
|
||||
__attribute__((section(".isr_vector")))
|
||||
const tIsrFunc _vectab[] =
|
||||
{
|
||||
{ .ptr = (blt_int32u)&_estack }, /* the initial stack pointer */
|
||||
{ .ptr = (blt_int32u) &_estack }, /* the initial stack pointer */
|
||||
{ reset_handler }, /* the reset handler */
|
||||
{ UnusedISR }, /* NMI Handler */
|
||||
{ UnusedISR }, /* Hard Fault Handler */
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
/****************************************************************************************
|
||||
* External functions
|
||||
****************************************************************************************/
|
||||
extern void reset_handler( void );
|
||||
extern void reset_handler(void);
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
|
@ -51,7 +51,7 @@ typedef union
|
|||
{
|
||||
void (*func)(void); /**< for ISR function pointers */
|
||||
void *ptr; /**< for stack pointer entry */
|
||||
}tIsrFunc;
|
||||
} tIsrFunc;
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
|
@ -75,7 +75,7 @@ void UnusedISR(void)
|
|||
/** \brief Interrupt vector table. */
|
||||
__root const tIsrFunc __vector_table[] @ ".intvec" =
|
||||
{
|
||||
{ .ptr = __sfe( "CSTACK" ) }, /* the initial stack pointer */
|
||||
{ .ptr = __sfe("CSTACK") }, /* the initial stack pointer */
|
||||
{ &reset_handler }, /* the reset handler */
|
||||
{ UnusedISR }, /* NMI Handler */
|
||||
{ UnusedISR }, /* Hard Fault Handler */
|
||||
|
|
|
@ -83,18 +83,18 @@ void CpuStartUserProgram(void)
|
|||
/* not a valid user program so it cannot be started */
|
||||
return;
|
||||
}
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
/* invoke callback */
|
||||
if (CpuUserProgramStartHook() == BLT_FALSE)
|
||||
{
|
||||
/* callback requests the user program to not be started */
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
/* release the communication interface */
|
||||
ComFree();
|
||||
#endif
|
||||
#endif
|
||||
/* reset the timer */
|
||||
TimerReset();
|
||||
/* remap user program's vector table */
|
||||
|
@ -103,7 +103,7 @@ void CpuStartUserProgram(void)
|
|||
* the 2nd entry in the user program's vector table. this address points to the
|
||||
* user program's reset handler.
|
||||
*/
|
||||
pProgResetHandler = (void(*)(void))(*((blt_addr*)CPU_USER_PROGRAM_STARTADDR_PTR));
|
||||
pProgResetHandler = (void(*)(void))(*((blt_addr *)CPU_USER_PROGRAM_STARTADDR_PTR));
|
||||
/* start the user program by activating its reset interrupt service routine */
|
||||
pProgResetHandler();
|
||||
} /*** end of CpuStartUserProgram ***/
|
||||
|
@ -126,7 +126,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
|
|||
to = (blt_int8u *)dest;
|
||||
|
||||
/* copy all bytes from source address to destination address */
|
||||
while(len-- > 0)
|
||||
while (len-- > 0)
|
||||
{
|
||||
/* store byte value from source to destination */
|
||||
*to++ = *from++;
|
||||
|
|
|
@ -219,8 +219,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
|
|||
blt_addr base_addr;
|
||||
|
||||
/* make sure the addresses are within the flash device */
|
||||
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
|
||||
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
|
|||
first_sector = FlashGetSector(addr);
|
||||
last_sector = FlashGetSector(addr+len-1);
|
||||
/* check them */
|
||||
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
|
||||
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -309,19 +309,19 @@ blt_bool FlashWriteChecksum(void)
|
|||
/* compute the checksum. note that the user program's vectors are not yet written
|
||||
* to flash but are present in the bootblock data structure at this point.
|
||||
*/
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x00]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x04]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x08]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x0C]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x10]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x14]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x18]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x00]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x04]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x08]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x0C]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x10]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x14]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x18]));
|
||||
signature_checksum = ~signature_checksum; /* one's complement */
|
||||
signature_checksum += 1; /* two's complement */
|
||||
|
||||
/* write the checksum */
|
||||
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
|
||||
sizeof(blt_addr), (blt_int8u*)&signature_checksum);
|
||||
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
|
||||
} /*** end of FlashWriteChecksum ***/
|
||||
|
||||
|
||||
|
@ -336,14 +336,14 @@ blt_bool FlashVerifyChecksum(void)
|
|||
blt_int32u signature_checksum = 0;
|
||||
|
||||
/* verify the checksum based on how it was written by CpuWriteChecksum() */
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x04));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x08));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x0C));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x10));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x14));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x18));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x04));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x08));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
|
||||
/* sum should add up to an unsigned 32-bit value of 0 */
|
||||
if (signature_checksum == 0)
|
||||
{
|
||||
|
@ -579,7 +579,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
for (word_cnt=0; word_cnt<(FLASH_WRITE_BLOCK_SIZE/sizeof(blt_int32u)); word_cnt++)
|
||||
{
|
||||
prog_addr = block->base_addr + (word_cnt * sizeof(blt_int32u));
|
||||
prog_data = *(volatile blt_int32u*)(&block->data[word_cnt * sizeof(blt_int32u)]);
|
||||
prog_data = *(volatile blt_int32u *)(&block->data[word_cnt * sizeof(blt_int32u)]);
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* program a word */
|
||||
|
@ -589,7 +589,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
break;
|
||||
}
|
||||
/* verify that the written data is actually there */
|
||||
if (*(volatile blt_int32u*)prog_addr != prog_data)
|
||||
if (*(volatile blt_int32u *)prog_addr != prog_data)
|
||||
{
|
||||
result = BLT_FALSE;
|
||||
break;
|
||||
|
@ -608,14 +608,14 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
****************************************************************************************/
|
||||
static blt_int32u FlashCalcPageSize(void)
|
||||
{
|
||||
blt_int8u family = *(blt_int8u*)0x0FE081FE;
|
||||
blt_int8u family = *(blt_int8u *)0x0FE081FE;
|
||||
|
||||
if ( ( family == 71 ) || ( family == 73 ) )
|
||||
if ((family == 71) || (family == 73))
|
||||
{
|
||||
/* Gecko and Tiny, 'G' or 'I' */
|
||||
return 512;
|
||||
}
|
||||
else if ( family == 72 )
|
||||
else if (family == 72)
|
||||
{
|
||||
/* Giant, 'H' */
|
||||
return 4096;
|
||||
|
@ -648,8 +648,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
if ( (first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
|
||||
if ((first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -693,9 +693,9 @@ static blt_int8u FlashGetSector(blt_addr address)
|
|||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* is the address in this sector? */
|
||||
if ( (address >= flashLayout[sectorIdx].sector_start) && \
|
||||
if ((address >= flashLayout[sectorIdx].sector_start) && \
|
||||
(address < (flashLayout[sectorIdx].sector_start + \
|
||||
flashLayout[sectorIdx].sector_size)) )
|
||||
flashLayout[sectorIdx].sector_size)))
|
||||
{
|
||||
/* return the sector number */
|
||||
return flashLayout[sectorIdx].sector_num;
|
||||
|
|
|
@ -233,7 +233,7 @@ static blt_bool UartTransmitByte(blt_int8u data)
|
|||
/* write byte to transmit holding register */
|
||||
LEUART_Tx(LEUART1, data);
|
||||
/* wait for tx holding register to be empty */
|
||||
while((LEUART1->STATUS & LEUART_STATUS_TXBL) == 0)
|
||||
while ((LEUART1->STATUS & LEUART_STATUS_TXBL) == 0)
|
||||
{
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
|
|
|
@ -70,13 +70,13 @@ typedef union
|
|||
{
|
||||
void (*func)(void); /**< for ISR function pointers */
|
||||
blt_int32u ptr; /**< for stack pointer entry */
|
||||
}tIsrFunc;
|
||||
} tIsrFunc;
|
||||
|
||||
/** \brief Interrupt vector table. */
|
||||
__attribute__ ((section(".vectors")))
|
||||
__attribute__((section(".vectors")))
|
||||
const tIsrFunc _vectors[] =
|
||||
{
|
||||
{ .ptr = (blt_int32u)&__stack_end__ }, /* the initial stack pointer */
|
||||
{ .ptr = (blt_int32u) &__stack_end__ }, /* the initial stack pointer */
|
||||
reset_handler, /* the reset handler */
|
||||
UnusedISR, /* NMI Handler */
|
||||
UnusedISR, /* Hard Fault Handler */
|
||||
|
|
|
@ -69,7 +69,7 @@ void reset_handler(void)
|
|||
__asm(" cpsid i");
|
||||
/* copy the data segment initializers from flash to SRAM */
|
||||
pSrc = &_etext;
|
||||
for(pDest = &_data; pDest < &_edata; )
|
||||
for (pDest = &_data; pDest < &_edata;)
|
||||
{
|
||||
*pDest++ = *pSrc++;
|
||||
}
|
||||
|
|
|
@ -64,13 +64,13 @@ typedef union
|
|||
{
|
||||
void (*func)(void); /**< for ISR function pointers */
|
||||
blt_int32u ptr; /**< for stack pointer entry */
|
||||
}tIsrFunc;
|
||||
} tIsrFunc;
|
||||
|
||||
/** \brief Interrupt vector table. */
|
||||
__attribute__ ((section(".isr_vector")))
|
||||
__attribute__((section(".isr_vector")))
|
||||
const tIsrFunc _vectab[] =
|
||||
{
|
||||
{ .ptr = (blt_int32u)&_estack }, /* the initial stack pointer */
|
||||
{ .ptr = (blt_int32u) &_estack }, /* the initial stack pointer */
|
||||
{ reset_handler }, /* the reset handler */
|
||||
{ UnusedISR }, /* NMI Handler */
|
||||
{ UnusedISR }, /* Hard Fault Handler */
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
/****************************************************************************************
|
||||
* External functions
|
||||
****************************************************************************************/
|
||||
extern void reset_handler( void );
|
||||
extern void reset_handler(void);
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
|
@ -51,7 +51,7 @@ typedef union
|
|||
{
|
||||
void (*func)(void); /**< for ISR function pointers */
|
||||
void *ptr; /**< for stack pointer entry */
|
||||
}tIsrFunc;
|
||||
} tIsrFunc;
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
|
@ -75,7 +75,7 @@ void UnusedISR(void)
|
|||
/** \brief Interrupt vector table. */
|
||||
__root const tIsrFunc __vector_table[] @ ".intvec" =
|
||||
{
|
||||
{ .ptr = __sfe( "CSTACK" ) }, /* the initial stack pointer */
|
||||
{ .ptr = __sfe("CSTACK") }, /* the initial stack pointer */
|
||||
{ &reset_handler }, /* the reset handler */
|
||||
{ UnusedISR }, /* NMI Handler */
|
||||
{ UnusedISR }, /* Hard Fault Handler */
|
||||
|
|
|
@ -91,7 +91,7 @@ static blt_int8u CanSetBittiming(void)
|
|||
{
|
||||
samplepoint = ((1+bitClkParms.uSyncPropPhase1Seg) * 100) / (1+bitClkParms.uSyncPropPhase1Seg+bitClkParms.uPhase2Seg);
|
||||
/* check that sample points is within the preferred range */
|
||||
if ( (samplepoint >= 65) && (samplepoint <= 75) )
|
||||
if ((samplepoint >= 65) && (samplepoint <= 75))
|
||||
{
|
||||
/* does a prescaler exist to get the exact baudrate with these bittiming
|
||||
* settings?
|
||||
|
|
|
@ -83,18 +83,18 @@ void CpuStartUserProgram(void)
|
|||
/* not a valid user program so it cannot be started */
|
||||
return;
|
||||
}
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
/* invoke callback */
|
||||
if (CpuUserProgramStartHook() == BLT_FALSE)
|
||||
{
|
||||
/* callback requests the user program to not be started */
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
/* release the communication interface */
|
||||
ComFree();
|
||||
#endif
|
||||
#endif
|
||||
/* reset the timer */
|
||||
TimerReset();
|
||||
/* remap user program's vector table */
|
||||
|
@ -103,7 +103,7 @@ void CpuStartUserProgram(void)
|
|||
* the 2nd entry in the user program's vector table. this address points to the
|
||||
* user program's reset handler.
|
||||
*/
|
||||
pProgResetHandler = (void(*)(void))(*((blt_addr*)CPU_USER_PROGRAM_STARTADDR_PTR));
|
||||
pProgResetHandler = (void(*)(void))(*((blt_addr *)CPU_USER_PROGRAM_STARTADDR_PTR));
|
||||
/* start the user program by activating its reset interrupt service routine */
|
||||
pProgResetHandler();
|
||||
} /*** end of CpuStartUserProgram ***/
|
||||
|
@ -126,7 +126,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
|
|||
to = (blt_int8u *)dest;
|
||||
|
||||
/* copy all bytes from source address to destination address */
|
||||
while(len-- > 0)
|
||||
while (len-- > 0)
|
||||
{
|
||||
/* store byte value from source to destination */
|
||||
*to++ = *from++;
|
||||
|
|
|
@ -220,8 +220,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
|
|||
blt_addr base_addr;
|
||||
|
||||
/* make sure the addresses are within the flash device */
|
||||
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
|
||||
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
|
|||
first_sector = FlashGetSector(addr);
|
||||
last_sector = FlashGetSector(addr+len-1);
|
||||
/* check them */
|
||||
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
|
||||
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -310,19 +310,19 @@ blt_bool FlashWriteChecksum(void)
|
|||
/* compute the checksum. note that the user program's vectors are not yet written
|
||||
* to flash but are present in the bootblock data structure at this point.
|
||||
*/
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x00]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x04]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x08]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x0C]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x10]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x14]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x18]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x00]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x04]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x08]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x0C]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x10]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x14]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x18]));
|
||||
signature_checksum = ~signature_checksum; /* one's complement */
|
||||
signature_checksum += 1; /* two's complement */
|
||||
|
||||
/* write the checksum */
|
||||
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
|
||||
sizeof(blt_addr), (blt_int8u*)&signature_checksum);
|
||||
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
|
||||
} /*** end of FlashWriteChecksum ***/
|
||||
|
||||
|
||||
|
@ -337,14 +337,14 @@ blt_bool FlashVerifyChecksum(void)
|
|||
blt_int32u signature_checksum = 0;
|
||||
|
||||
/* verify the checksum based on how it was written by CpuWriteChecksum() */
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x04));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x08));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x0C));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x10));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x14));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x18));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x04));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x08));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
|
||||
/* sum should add up to an unsigned 32-bit value of 0 */
|
||||
if (signature_checksum == 0)
|
||||
{
|
||||
|
@ -576,7 +576,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
for (word_cnt=0; word_cnt<(FLASH_WRITE_BLOCK_SIZE/sizeof(blt_int32u)); word_cnt++)
|
||||
{
|
||||
prog_addr = block->base_addr + (word_cnt * sizeof(blt_int32u));
|
||||
prog_data = *(volatile blt_int32u*)(&block->data[word_cnt * sizeof(blt_int32u)]);
|
||||
prog_data = *(volatile blt_int32u *)(&block->data[word_cnt * sizeof(blt_int32u)]);
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* program the word to flash */
|
||||
|
@ -586,7 +586,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
break;
|
||||
}
|
||||
/* verify that the written data is actually there */
|
||||
if (*(volatile blt_int32u*)prog_addr != prog_data)
|
||||
if (*(volatile blt_int32u *)prog_addr != prog_data)
|
||||
{
|
||||
result = BLT_FALSE;
|
||||
break;
|
||||
|
@ -616,8 +616,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
if ( (first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
|
||||
if ((first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -658,9 +658,9 @@ static blt_int8u FlashGetSector(blt_addr address)
|
|||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* is the address in this sector? */
|
||||
if ( (address >= flashLayout[sectorIdx].sector_start) && \
|
||||
if ((address >= flashLayout[sectorIdx].sector_start) && \
|
||||
(address < (flashLayout[sectorIdx].sector_start + \
|
||||
flashLayout[sectorIdx].sector_size)) )
|
||||
flashLayout[sectorIdx].sector_size)))
|
||||
{
|
||||
/* return the sector number */
|
||||
return flashLayout[sectorIdx].sector_num;
|
||||
|
|
|
@ -190,7 +190,7 @@ static blt_bool UartReceiveByte(blt_int8u *data)
|
|||
/* try to read a newly received byte */
|
||||
result = UARTCharGetNonBlocking(UART0_BASE);
|
||||
/* check if a new byte was received */
|
||||
if(result != -1)
|
||||
if (result != -1)
|
||||
{
|
||||
/* store the received byte */
|
||||
data[0] = (blt_int8u)result;
|
||||
|
@ -217,7 +217,7 @@ static blt_bool UartTransmitByte(blt_int8u data)
|
|||
return BLT_FALSE;
|
||||
}
|
||||
/* wait for tx holding register to be empty */
|
||||
while(UARTSpaceAvail(UART0_BASE) == false)
|
||||
while (UARTSpaceAvail(UART0_BASE) == false)
|
||||
{
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
|
|
|
@ -70,13 +70,13 @@ typedef union
|
|||
{
|
||||
void (*func)(void); /**< for ISR function pointers */
|
||||
blt_int32u ptr; /**< for stack pointer entry */
|
||||
}tIsrFunc;
|
||||
} tIsrFunc;
|
||||
|
||||
/** \brief Interrupt vector table. */
|
||||
__attribute__ ((section(".vectors")))
|
||||
__attribute__((section(".vectors")))
|
||||
const tIsrFunc _vectors[] =
|
||||
{
|
||||
{ .ptr = (blt_int32u)&__stack_end__ }, /* the initial stack pointer */
|
||||
{ .ptr = (blt_int32u) &__stack_end__ }, /* the initial stack pointer */
|
||||
reset_handler, /* the reset handler */
|
||||
UnusedISR, /* NMI Handler */
|
||||
UnusedISR, /* Hard Fault Handler */
|
||||
|
|
|
@ -69,7 +69,7 @@ void reset_handler(void)
|
|||
__asm(" cpsid i");
|
||||
/* copy the data segment initializers from flash to SRAM */
|
||||
pSrc = &_etext;
|
||||
for(pDest = &_data; pDest < &_edata; )
|
||||
for (pDest = &_data; pDest < &_edata;)
|
||||
{
|
||||
*pDest++ = *pSrc++;
|
||||
}
|
||||
|
|
|
@ -64,13 +64,13 @@ typedef union
|
|||
{
|
||||
void (*func)(void); /**< for ISR function pointers */
|
||||
blt_int32u ptr; /**< for stack pointer entry */
|
||||
}tIsrFunc;
|
||||
} tIsrFunc;
|
||||
|
||||
/** \brief Interrupt vector table. */
|
||||
__attribute__ ((section(".isr_vector")))
|
||||
__attribute__((section(".isr_vector")))
|
||||
const tIsrFunc _vectab[] =
|
||||
{
|
||||
{ .ptr = (blt_int32u)&_estack }, /* the initial stack pointer */
|
||||
{ .ptr = (blt_int32u) &_estack }, /* the initial stack pointer */
|
||||
{ reset_handler }, /* the reset handler */
|
||||
{ UnusedISR }, /* NMI Handler */
|
||||
{ UnusedISR }, /* Hard Fault Handler */
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
/****************************************************************************************
|
||||
* External functions
|
||||
****************************************************************************************/
|
||||
extern void reset_handler( void );
|
||||
extern void reset_handler(void);
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
|
@ -51,7 +51,7 @@ typedef union
|
|||
{
|
||||
void (*func)(void); /**< for ISR function pointers */
|
||||
void *ptr; /**< for stack pointer entry */
|
||||
}tIsrFunc;
|
||||
} tIsrFunc;
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
|
@ -75,7 +75,7 @@ void UnusedISR(void)
|
|||
/** \brief Interrupt vector table. */
|
||||
__root const tIsrFunc __vector_table[] @ ".intvec" =
|
||||
{
|
||||
{ .ptr = __sfe( "CSTACK" ) }, /* the initial stack pointer */
|
||||
{ .ptr = __sfe("CSTACK") }, /* the initial stack pointer */
|
||||
{ &reset_handler }, /* the reset handler */
|
||||
{ UnusedISR }, /* NMI Handler */
|
||||
{ UnusedISR }, /* Hard Fault Handler */
|
||||
|
|
|
@ -147,7 +147,8 @@ typedef struct t_can_bus_timing
|
|||
* a sample point between 68..78%.
|
||||
*/
|
||||
static const tCanBusTiming canTiming[] =
|
||||
{ /* TQ | TSEG1 | TSEG2 | SP */
|
||||
{
|
||||
/* TQ | TSEG1 | TSEG2 | SP */
|
||||
/* ------------------------- */
|
||||
{ 5, 2 }, /* 8 | 5 | 2 | 75% */
|
||||
{ 6, 2 }, /* 9 | 6 | 2 | 78% */
|
||||
|
@ -195,7 +196,7 @@ static blt_bool CanGetSpeedConfig(blt_int16u baud, blt_int16u *prescaler,
|
|||
*prescaler = (BOOT_CPU_SYSTEM_SPEED_KHZ/2)/(baud*(canTiming[cnt].tseg1+canTiming[cnt].tseg2+1));
|
||||
|
||||
/* make sure the prescaler is valid */
|
||||
if ( (*prescaler > 0) && (*prescaler <= 1024) )
|
||||
if ((*prescaler > 0) && (*prescaler <= 1024))
|
||||
{
|
||||
/* store the bustiming configuration */
|
||||
*tseg1 = canTiming[cnt].tseg1;
|
||||
|
|
|
@ -83,18 +83,18 @@ void CpuStartUserProgram(void)
|
|||
/* not a valid user program so it cannot be started */
|
||||
return;
|
||||
}
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
/* invoke callback */
|
||||
if (CpuUserProgramStartHook() == BLT_FALSE)
|
||||
{
|
||||
/* callback requests the user program to not be started */
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
/* release the communication interface */
|
||||
ComFree();
|
||||
#endif
|
||||
#endif
|
||||
/* reset the timer */
|
||||
TimerReset();
|
||||
/* remap user program's vector table */
|
||||
|
@ -103,7 +103,7 @@ void CpuStartUserProgram(void)
|
|||
* the 2nd entry in the user program's vector table. this address points to the
|
||||
* user program's reset handler.
|
||||
*/
|
||||
pProgResetHandler = (void(*)(void))(*((blt_addr*)CPU_USER_PROGRAM_STARTADDR_PTR));
|
||||
pProgResetHandler = (void(*)(void))(*((blt_addr *)CPU_USER_PROGRAM_STARTADDR_PTR));
|
||||
/* start the user program by activating its reset interrupt service routine */
|
||||
pProgResetHandler();
|
||||
} /*** end of CpuStartUserProgram ***/
|
||||
|
@ -126,7 +126,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
|
|||
to = (blt_int8u *)dest;
|
||||
|
||||
/* copy all bytes from source address to destination address */
|
||||
while(len-- > 0)
|
||||
while (len-- > 0)
|
||||
{
|
||||
/* store byte value from source to destination */
|
||||
*to++ = *from++;
|
||||
|
|
|
@ -250,8 +250,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
|
|||
blt_addr base_addr;
|
||||
|
||||
/* make sure the addresses are within the flash device */
|
||||
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
|
||||
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
|
|||
first_sector = FlashGetSector(addr);
|
||||
last_sector = FlashGetSector(addr+len-1);
|
||||
/* check them */
|
||||
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
|
||||
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -340,19 +340,19 @@ blt_bool FlashWriteChecksum(void)
|
|||
/* compute the checksum. note that the user program's vectors are not yet written
|
||||
* to flash but are present in the bootblock data structure at this point.
|
||||
*/
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x00]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x04]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x08]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x0C]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x10]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x14]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x18]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x00]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x04]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x08]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x0C]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x10]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x14]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x18]));
|
||||
signature_checksum = ~signature_checksum; /* one's complement */
|
||||
signature_checksum += 1; /* two's complement */
|
||||
|
||||
/* write the checksum */
|
||||
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
|
||||
sizeof(blt_addr), (blt_int8u*)&signature_checksum);
|
||||
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
|
||||
} /*** end of FlashWriteChecksum ***/
|
||||
|
||||
|
||||
|
@ -367,14 +367,14 @@ blt_bool FlashVerifyChecksum(void)
|
|||
blt_int32u signature_checksum = 0;
|
||||
|
||||
/* verify the checksum based on how it was written by CpuWriteChecksum() */
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x04));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x08));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x0C));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x10));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x14));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x18));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x04));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x08));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
|
||||
/* sum should add up to an unsigned 32-bit value of 0 */
|
||||
if (signature_checksum == 0)
|
||||
{
|
||||
|
@ -618,9 +618,9 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
for (word_cnt=0; word_cnt<(FLASH_WRITE_BLOCK_SIZE/sizeof(blt_int32u)); word_cnt++)
|
||||
{
|
||||
prog_addr = block->base_addr + (word_cnt * sizeof(blt_int32u));
|
||||
prog_data = *(volatile blt_int32u*)(&block->data[word_cnt * sizeof(blt_int32u)]);
|
||||
prog_data = *(volatile blt_int32u *)(&block->data[word_cnt * sizeof(blt_int32u)]);
|
||||
/* program the first half word */
|
||||
*(volatile blt_int16u*)prog_addr = (blt_int16u)prog_data;
|
||||
*(volatile blt_int16u *)prog_addr = (blt_int16u)prog_data;
|
||||
/* wait for the program operation to complete */
|
||||
while ((FLASH->SR & FLASH_BSY_BIT) == FLASH_BSY_BIT)
|
||||
{
|
||||
|
@ -628,7 +628,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
CopService();
|
||||
}
|
||||
/* program the second half word */
|
||||
*(volatile blt_int16u*)(prog_addr+2) = (blt_int16u)(prog_data >> 16);
|
||||
*(volatile blt_int16u *)(prog_addr+2) = (blt_int16u)(prog_data >> 16);
|
||||
/* wait for the program operation to complete */
|
||||
while ((FLASH->SR & FLASH_BSY_BIT) == FLASH_BSY_BIT)
|
||||
{
|
||||
|
@ -636,7 +636,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
CopService();
|
||||
}
|
||||
/* verify that the written data is actually there */
|
||||
if (*(volatile blt_int32u*)prog_addr != prog_data)
|
||||
if (*(volatile blt_int32u *)prog_addr != prog_data)
|
||||
{
|
||||
result = BLT_FALSE;
|
||||
break;
|
||||
|
@ -670,8 +670,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
if ( (first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
|
||||
if ((first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -761,9 +761,9 @@ static blt_int8u FlashGetSector(blt_addr address)
|
|||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* is the address in this sector? */
|
||||
if ( (address >= flashLayout[sectorIdx].sector_start) && \
|
||||
if ((address >= flashLayout[sectorIdx].sector_start) && \
|
||||
(address < (flashLayout[sectorIdx].sector_start + \
|
||||
flashLayout[sectorIdx].sector_size)) )
|
||||
flashLayout[sectorIdx].sector_size)))
|
||||
{
|
||||
/* return the sector number */
|
||||
return flashLayout[sectorIdx].sector_num;
|
||||
|
|
|
@ -236,7 +236,7 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
static blt_bool UartReceiveByte(blt_int8u *data)
|
||||
{
|
||||
/* check if a new byte was received by means of the RDR-bit */
|
||||
if((UARTx->SR & UART_BIT_RXNE) != 0)
|
||||
if ((UARTx->SR & UART_BIT_RXNE) != 0)
|
||||
{
|
||||
/* store the received byte */
|
||||
data[0] = UARTx->DR;
|
||||
|
@ -265,7 +265,7 @@ static blt_bool UartTransmitByte(blt_int8u data)
|
|||
/* write byte to transmit holding register */
|
||||
UARTx->DR = data;
|
||||
/* wait for tx holding register to be empty */
|
||||
while((UARTx->SR & UART_BIT_TXE) == 0)
|
||||
while ((UARTx->SR & UART_BIT_TXE) == 0)
|
||||
{
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
|
|
|
@ -123,8 +123,8 @@ void UsbInit(void)
|
|||
fifoPipeBulkIN.handle = UsbFifoMgrCreate(fifoPipeBulkIN.data, FIFO_PIPE_SIZE);
|
||||
fifoPipeBulkOUT.handle = UsbFifoMgrCreate(fifoPipeBulkOUT.data, FIFO_PIPE_SIZE);
|
||||
/* validate fifo handles */
|
||||
ASSERT_RT( (fifoPipeBulkIN.handle != FIFO_ERR_INVALID_HANDLE) && \
|
||||
(fifoPipeBulkOUT.handle != FIFO_ERR_INVALID_HANDLE) );
|
||||
ASSERT_RT((fifoPipeBulkIN.handle != FIFO_ERR_INVALID_HANDLE) && \
|
||||
(fifoPipeBulkOUT.handle != FIFO_ERR_INVALID_HANDLE));
|
||||
/* initialize the low level USB driver */
|
||||
USB_Init();
|
||||
} /*** end of UsbInit ***/
|
||||
|
@ -383,13 +383,13 @@ void UsbReceivePipeBulkOUT(void)
|
|||
** \return none.
|
||||
**
|
||||
****************************************************************************************/
|
||||
static void IntToUnicode (blt_int32u value , blt_int8u *pbuf , blt_int8u len)
|
||||
static void IntToUnicode(blt_int32u value , blt_int8u *pbuf , blt_int8u len)
|
||||
{
|
||||
blt_int8u idx = 0;
|
||||
|
||||
for( idx = 0 ; idx < len ; idx ++)
|
||||
for (idx = 0 ; idx < len ; idx ++)
|
||||
{
|
||||
if( ((value >> 28)) < 0xA )
|
||||
if (((value >> 28)) < 0xA)
|
||||
{
|
||||
pbuf[ 2* idx] = (value >> 28) + '0';
|
||||
}
|
||||
|
@ -414,9 +414,9 @@ void UsbGetSerialNum(void)
|
|||
{
|
||||
blt_int32u Device_Serial0, Device_Serial1, Device_Serial2;
|
||||
|
||||
Device_Serial0 = *(volatile blt_int32u*)(0x1FFFF7E8);
|
||||
Device_Serial1 = *(volatile blt_int32u*)(0x1FFFF7EC);
|
||||
Device_Serial2 = *(volatile blt_int32u*)(0x1FFFF7F0);
|
||||
Device_Serial0 = *(volatile blt_int32u *)(0x1FFFF7E8);
|
||||
Device_Serial1 = *(volatile blt_int32u *)(0x1FFFF7EC);
|
||||
Device_Serial2 = *(volatile blt_int32u *)(0x1FFFF7F0);
|
||||
|
||||
Device_Serial0 += Device_Serial2;
|
||||
|
||||
|
@ -488,7 +488,7 @@ static blt_int8u UsbFifoMgrCreate(blt_int8u *buffer, blt_int8u length)
|
|||
pbc->writeptr = buffer;
|
||||
pbc->entries = 0;
|
||||
pbc->startptr = buffer;
|
||||
pbc->endptr = (blt_int8u*)(buffer + length - 1);
|
||||
pbc->endptr = (blt_int8u *)(buffer + length - 1);
|
||||
|
||||
/* return the handle to the successfully created fifo control */
|
||||
return pbc->handle;
|
||||
|
|
|
@ -70,13 +70,13 @@ typedef union
|
|||
{
|
||||
void (*func)(void); /**< for ISR function pointers */
|
||||
blt_int32u ptr; /**< for stack pointer entry */
|
||||
}tIsrFunc;
|
||||
} tIsrFunc;
|
||||
|
||||
/** \brief Interrupt vector table. */
|
||||
__attribute__ ((section(".vectors")))
|
||||
__attribute__((section(".vectors")))
|
||||
const tIsrFunc _vectors[] =
|
||||
{
|
||||
{ .ptr = (blt_int32u)&__stack_end__ }, /* the initial stack pointer */
|
||||
{ .ptr = (blt_int32u) &__stack_end__ }, /* the initial stack pointer */
|
||||
reset_handler, /* the reset handler */
|
||||
UnusedISR, /* NMI Handler */
|
||||
UnusedISR, /* Hard Fault Handler */
|
||||
|
|
|
@ -69,7 +69,7 @@ void reset_handler(void)
|
|||
__asm(" cpsid i");
|
||||
/* copy the data segment initializers from flash to SRAM */
|
||||
pSrc = &_etext;
|
||||
for(pDest = &_data; pDest < &_edata; )
|
||||
for (pDest = &_data; pDest < &_edata;)
|
||||
{
|
||||
*pDest++ = *pSrc++;
|
||||
}
|
||||
|
|
|
@ -64,13 +64,13 @@ typedef union
|
|||
{
|
||||
void (*func)(void); /**< for ISR function pointers */
|
||||
blt_int32u ptr; /**< for stack pointer entry */
|
||||
}tIsrFunc;
|
||||
} tIsrFunc;
|
||||
|
||||
/** \brief Interrupt vector table. */
|
||||
__attribute__ ((section(".isr_vector")))
|
||||
__attribute__((section(".isr_vector")))
|
||||
const tIsrFunc _vectab[] =
|
||||
{
|
||||
{ .ptr = (blt_int32u)&_estack }, /* the initial stack pointer */
|
||||
{ .ptr = (blt_int32u) &_estack }, /* the initial stack pointer */
|
||||
{ reset_handler }, /* the reset handler */
|
||||
{ UnusedISR }, /* NMI Handler */
|
||||
{ UnusedISR }, /* Hard Fault Handler */
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
/****************************************************************************************
|
||||
* External functions
|
||||
****************************************************************************************/
|
||||
extern void reset_handler( void );
|
||||
extern void reset_handler(void);
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
|
@ -51,7 +51,7 @@ typedef union
|
|||
{
|
||||
void (*func)(void); /**< for ISR function pointers */
|
||||
void *ptr; /**< for stack pointer entry */
|
||||
}tIsrFunc;
|
||||
} tIsrFunc;
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
|
@ -75,7 +75,7 @@ void UnusedISR(void)
|
|||
/** \brief Interrupt vector table. */
|
||||
__root const tIsrFunc __vector_table[] @ ".intvec" =
|
||||
{
|
||||
{ .ptr = __sfe( "CSTACK" ) }, /* the initial stack pointer */
|
||||
{ .ptr = __sfe("CSTACK") }, /* the initial stack pointer */
|
||||
{ &reset_handler }, /* the reset handler */
|
||||
{ UnusedISR }, /* NMI Handler */
|
||||
{ UnusedISR }, /* Hard Fault Handler */
|
||||
|
|
|
@ -156,7 +156,8 @@ typedef struct t_can_bus_timing
|
|||
* a sample point between 68..78%.
|
||||
*/
|
||||
static const tCanBusTiming canTiming[] =
|
||||
{ /* TQ | TSEG1 | TSEG2 | SP */
|
||||
{
|
||||
/* TQ | TSEG1 | TSEG2 | SP */
|
||||
/* ------------------------- */
|
||||
{ 5, 2 }, /* 8 | 5 | 2 | 75% */
|
||||
{ 6, 2 }, /* 9 | 6 | 2 | 78% */
|
||||
|
@ -204,7 +205,7 @@ static blt_bool CanGetSpeedConfig(blt_int16u baud, blt_int16u *prescaler,
|
|||
*prescaler = (BOOT_CPU_SYSTEM_SPEED_KHZ/4)/(baud*(canTiming[cnt].tseg1+canTiming[cnt].tseg2+1));
|
||||
|
||||
/* make sure the prescaler is valid */
|
||||
if ( (*prescaler > 0) && (*prescaler <= 1024) )
|
||||
if ((*prescaler > 0) && (*prescaler <= 1024))
|
||||
{
|
||||
/* store the bustiming configuration */
|
||||
*tseg1 = canTiming[cnt].tseg1;
|
||||
|
|
|
@ -83,18 +83,18 @@ void CpuStartUserProgram(void)
|
|||
/* not a valid user program so it cannot be started */
|
||||
return;
|
||||
}
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
/* invoke callback */
|
||||
if (CpuUserProgramStartHook() == BLT_FALSE)
|
||||
{
|
||||
/* callback requests the user program to not be started */
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
/* release the communication interface */
|
||||
ComFree();
|
||||
#endif
|
||||
#endif
|
||||
/* reset the timer */
|
||||
TimerReset();
|
||||
/* remap user program's vector table */
|
||||
|
@ -103,7 +103,7 @@ void CpuStartUserProgram(void)
|
|||
* the 2nd entry in the user program's vector table. this address points to the
|
||||
* user program's reset handler.
|
||||
*/
|
||||
pProgResetHandler = (void(*)(void))(*((blt_addr*)CPU_USER_PROGRAM_STARTADDR_PTR));
|
||||
pProgResetHandler = (void(*)(void))(*((blt_addr *)CPU_USER_PROGRAM_STARTADDR_PTR));
|
||||
/* start the user program by activating its reset interrupt service routine */
|
||||
pProgResetHandler();
|
||||
} /*** end of CpuStartUserProgram ***/
|
||||
|
@ -126,7 +126,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
|
|||
to = (blt_int8u *)dest;
|
||||
|
||||
/* copy all bytes from source address to destination address */
|
||||
while(len-- > 0)
|
||||
while (len-- > 0)
|
||||
{
|
||||
/* store byte value from source to destination */
|
||||
*to++ = *from++;
|
||||
|
|
|
@ -235,8 +235,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
|
|||
blt_addr base_addr;
|
||||
|
||||
/* make sure the addresses are within the flash device */
|
||||
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
|
||||
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
|
|||
first_sector = FlashGetSector(addr);
|
||||
last_sector = FlashGetSector(addr+len-1);
|
||||
/* check them */
|
||||
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
|
||||
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -325,19 +325,19 @@ blt_bool FlashWriteChecksum(void)
|
|||
/* compute the checksum. note that the user program's vectors are not yet written
|
||||
* to flash but are present in the bootblock data structure at this point.
|
||||
*/
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x00]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x04]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x08]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x0C]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x10]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x14]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x18]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x00]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x04]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x08]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x0C]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x10]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x14]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x18]));
|
||||
signature_checksum = ~signature_checksum; /* one's complement */
|
||||
signature_checksum += 1; /* two's complement */
|
||||
|
||||
/* write the checksum */
|
||||
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
|
||||
sizeof(blt_addr), (blt_int8u*)&signature_checksum);
|
||||
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
|
||||
} /*** end of FlashWriteChecksum ***/
|
||||
|
||||
|
||||
|
@ -352,14 +352,14 @@ blt_bool FlashVerifyChecksum(void)
|
|||
blt_int32u signature_checksum = 0;
|
||||
|
||||
/* verify the checksum based on how it was written by CpuWriteChecksum() */
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x04));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x08));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x0C));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x10));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x14));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x18));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x04));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x08));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
|
||||
/* sum should add up to an unsigned 32-bit value of 0 */
|
||||
if (signature_checksum == 0)
|
||||
{
|
||||
|
@ -604,7 +604,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
for (word_cnt=0; word_cnt<(FLASH_WRITE_BLOCK_SIZE/sizeof(blt_int32u)); word_cnt++)
|
||||
{
|
||||
prog_addr = block->base_addr + (word_cnt * sizeof(blt_int32u));
|
||||
prog_data = *(volatile blt_int32u*)(&block->data[word_cnt * sizeof(blt_int32u)]);
|
||||
prog_data = *(volatile blt_int32u *)(&block->data[word_cnt * sizeof(blt_int32u)]);
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* program the word */
|
||||
|
@ -614,7 +614,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
break;
|
||||
}
|
||||
/* verify that the written data is actually there */
|
||||
if (*(volatile blt_int32u*)prog_addr != prog_data)
|
||||
if (*(volatile blt_int32u *)prog_addr != prog_data)
|
||||
{
|
||||
result = BLT_FALSE;
|
||||
break;
|
||||
|
@ -643,8 +643,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
if ( (first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
|
||||
if ((first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -698,9 +698,9 @@ static blt_int8u FlashGetSector(blt_addr address)
|
|||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* is the address in this sector? */
|
||||
if ( (address >= flashLayout[sectorIdx].sector_start) && \
|
||||
if ((address >= flashLayout[sectorIdx].sector_start) && \
|
||||
(address < (flashLayout[sectorIdx].sector_start + \
|
||||
flashLayout[sectorIdx].sector_size)) )
|
||||
flashLayout[sectorIdx].sector_size)))
|
||||
{
|
||||
/* return the sector number */
|
||||
return flashLayout[sectorIdx].sector_num;
|
||||
|
|
|
@ -122,8 +122,8 @@ void UsbInit(void)
|
|||
fifoPipeBulkIN.handle = UsbFifoMgrCreate(fifoPipeBulkIN.data, FIFO_PIPE_SIZE);
|
||||
fifoPipeBulkOUT.handle = UsbFifoMgrCreate(fifoPipeBulkOUT.data, FIFO_PIPE_SIZE);
|
||||
/* validate fifo handles */
|
||||
ASSERT_RT( (fifoPipeBulkIN.handle != FIFO_ERR_INVALID_HANDLE) && \
|
||||
(fifoPipeBulkOUT.handle != FIFO_ERR_INVALID_HANDLE) );
|
||||
ASSERT_RT((fifoPipeBulkIN.handle != FIFO_ERR_INVALID_HANDLE) && \
|
||||
(fifoPipeBulkOUT.handle != FIFO_ERR_INVALID_HANDLE));
|
||||
/* initialize the low level USB driver */
|
||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_bulk_cb, &USR_cb);
|
||||
} /*** end of UsbInit ***/
|
||||
|
@ -187,7 +187,7 @@ blt_bool UsbReceivePacket(blt_int8u *data)
|
|||
static blt_bool xcpCtoRxInProgress = BLT_FALSE;
|
||||
|
||||
/* poll USB interrupt flags to process USB related events */
|
||||
USBD_OTG_ISR_Handler (&USB_OTG_dev);
|
||||
USBD_OTG_ISR_Handler(&USB_OTG_dev);
|
||||
|
||||
/* start of cto packet received? */
|
||||
if (xcpCtoRxInProgress == BLT_FALSE)
|
||||
|
@ -394,7 +394,7 @@ static blt_int8u UsbFifoMgrCreate(blt_int8u *buffer, blt_int8u length)
|
|||
pbc->writeptr = buffer;
|
||||
pbc->entries = 0;
|
||||
pbc->startptr = buffer;
|
||||
pbc->endptr = (blt_int8u*)(buffer + length - 1);
|
||||
pbc->endptr = (blt_int8u *)(buffer + length - 1);
|
||||
|
||||
/* return the handle to the successfully created fifo control */
|
||||
return pbc->handle;
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
/****************************************************************************************
|
||||
* External functions
|
||||
****************************************************************************************/
|
||||
extern void reset_handler( void );
|
||||
extern void reset_handler(void);
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
|
@ -51,7 +51,7 @@ typedef union
|
|||
{
|
||||
void (*func)(void); /**< for ISR function pointers */
|
||||
void *ptr; /**< for stack pointer entry */
|
||||
}tIsrFunc;
|
||||
} tIsrFunc;
|
||||
|
||||
|
||||
/************************************************************************************//**
|
||||
|
@ -75,7 +75,7 @@ void UnusedISR(void)
|
|||
/** \brief Interrupt vector table. */
|
||||
__root const tIsrFunc __vector_table[] @ ".intvec" =
|
||||
{
|
||||
{ .ptr = __sfe( "CSTACK" ) }, /* the initial stack pointer */
|
||||
{ .ptr = __sfe("CSTACK") }, /* the initial stack pointer */
|
||||
{ &reset_handler }, /* the reset handler */
|
||||
{ UnusedISR }, /* NMI Handler */
|
||||
{ UnusedISR }, /* Hard Fault Handler */
|
||||
|
|
|
@ -83,18 +83,18 @@ void CpuStartUserProgram(void)
|
|||
/* not a valid user program so it cannot be started */
|
||||
return;
|
||||
}
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
/* invoke callback */
|
||||
if (CpuUserProgramStartHook() == BLT_FALSE)
|
||||
{
|
||||
/* callback requests the user program to not be started */
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
/* release the communication interface */
|
||||
ComFree();
|
||||
#endif
|
||||
#endif
|
||||
/* reset the timer */
|
||||
TimerReset();
|
||||
/* remap user program's vector table */
|
||||
|
@ -103,7 +103,7 @@ void CpuStartUserProgram(void)
|
|||
* the 2nd entry in the user program's vector table. this address points to the
|
||||
* user program's reset handler.
|
||||
*/
|
||||
pProgResetHandler = (void(*)(void))(*((blt_addr*)CPU_USER_PROGRAM_STARTADDR_PTR));
|
||||
pProgResetHandler = (void(*)(void))(*((blt_addr *)CPU_USER_PROGRAM_STARTADDR_PTR));
|
||||
/* start the user program by activating its reset interrupt service routine */
|
||||
pProgResetHandler();
|
||||
} /*** end of CpuStartUserProgram ***/
|
||||
|
@ -126,7 +126,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
|
|||
to = (blt_int8u *)dest;
|
||||
|
||||
/* copy all bytes from source address to destination address */
|
||||
while(len-- > 0)
|
||||
while (len-- > 0)
|
||||
{
|
||||
/* store byte value from source to destination */
|
||||
*to++ = *from++;
|
||||
|
|
|
@ -222,8 +222,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
|
|||
blt_addr base_addr;
|
||||
|
||||
/* make sure the addresses are within the flash device */
|
||||
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
|
||||
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
|
|||
first_sector = FlashGetSector(addr);
|
||||
last_sector = FlashGetSector(addr+len-1);
|
||||
/* check them */
|
||||
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
|
||||
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -312,19 +312,19 @@ blt_bool FlashWriteChecksum(void)
|
|||
/* compute the checksum. note that the user program's vectors are not yet written
|
||||
* to flash but are present in the bootblock data structure at this point.
|
||||
*/
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x00]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x04]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x08]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x0C]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x10]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x14]));
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[0+0x18]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x00]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x04]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x08]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x0C]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x10]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x14]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[0+0x18]));
|
||||
signature_checksum = ~signature_checksum; /* one's complement */
|
||||
signature_checksum += 1; /* two's complement */
|
||||
|
||||
/* write the checksum */
|
||||
return FlashWrite(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET,
|
||||
sizeof(blt_addr), (blt_int8u*)&signature_checksum);
|
||||
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
|
||||
} /*** end of FlashWriteChecksum ***/
|
||||
|
||||
|
||||
|
@ -339,14 +339,14 @@ blt_bool FlashVerifyChecksum(void)
|
|||
blt_int32u signature_checksum = 0;
|
||||
|
||||
/* verify the checksum based on how it was written by CpuWriteChecksum() */
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x04));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x08));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x0C));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x10));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x14));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+0x18));
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x04));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x08));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x0C));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x10));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x14));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+0x18));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start+FLASH_VECTOR_TABLE_CS_OFFSET));
|
||||
/* sum should add up to an unsigned 32-bit value of 0 */
|
||||
if (signature_checksum == 0)
|
||||
{
|
||||
|
@ -579,7 +579,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
for (word_cnt=0; word_cnt<(FLASH_WRITE_BLOCK_SIZE/sizeof(blt_int32u)); word_cnt++)
|
||||
{
|
||||
prog_addr = block->base_addr + (word_cnt * sizeof(blt_int32u));
|
||||
prog_data = *(volatile blt_int32u*)(&block->data[word_cnt * sizeof(blt_int32u)]);
|
||||
prog_data = *(volatile blt_int32u *)(&block->data[word_cnt * sizeof(blt_int32u)]);
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* program the word to flash */
|
||||
|
@ -589,7 +589,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
break;
|
||||
}
|
||||
/* verify that the written data is actually there */
|
||||
if (*(volatile blt_int32u*)prog_addr != prog_data)
|
||||
if (*(volatile blt_int32u *)prog_addr != prog_data)
|
||||
{
|
||||
result = BLT_FALSE;
|
||||
break;
|
||||
|
@ -619,8 +619,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
if ( (first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
|
||||
if ((first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -662,9 +662,9 @@ static blt_int8u FlashGetSector(blt_addr address)
|
|||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* is the address in this sector? */
|
||||
if ( (address >= flashLayout[sectorIdx].sector_start) && \
|
||||
if ((address >= flashLayout[sectorIdx].sector_start) && \
|
||||
(address < (flashLayout[sectorIdx].sector_start + \
|
||||
flashLayout[sectorIdx].sector_size)) )
|
||||
flashLayout[sectorIdx].sector_size)))
|
||||
{
|
||||
/* return the sector number */
|
||||
return flashLayout[sectorIdx].sector_num;
|
||||
|
|
|
@ -192,7 +192,7 @@ static blt_bool UartReceiveByte(blt_int8u *data)
|
|||
/* try to read a newly received byte */
|
||||
result = UARTCharGetNonBlocking(UART0_BASE);
|
||||
/* check if a new byte was received */
|
||||
if(result != -1)
|
||||
if (result != -1)
|
||||
{
|
||||
/* store the received byte */
|
||||
data[0] = (blt_int8u)result;
|
||||
|
@ -219,7 +219,7 @@ static blt_bool UartTransmitByte(blt_int8u data)
|
|||
return BLT_FALSE;
|
||||
}
|
||||
/* wait for tx holding register to be empty */
|
||||
while(UARTSpaceAvail(UART0_BASE) == false)
|
||||
while (UARTSpaceAvail(UART0_BASE) == false)
|
||||
{
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
|
|
|
@ -129,8 +129,8 @@ void UsbInit(void)
|
|||
fifoPipeBulkIN.handle = UsbFifoMgrCreate(fifoPipeBulkIN.data, FIFO_PIPE_SIZE);
|
||||
fifoPipeBulkOUT.handle = UsbFifoMgrCreate(fifoPipeBulkOUT.data, FIFO_PIPE_SIZE);
|
||||
/* validate fifo handles */
|
||||
ASSERT_RT( (fifoPipeBulkIN.handle != FIFO_ERR_INVALID_HANDLE) && \
|
||||
(fifoPipeBulkOUT.handle != FIFO_ERR_INVALID_HANDLE) );
|
||||
ASSERT_RT((fifoPipeBulkIN.handle != FIFO_ERR_INVALID_HANDLE) && \
|
||||
(fifoPipeBulkOUT.handle != FIFO_ERR_INVALID_HANDLE));
|
||||
/* initialize the transmit and receive buffers */
|
||||
USBBufferInit(&g_sTxBuffer);
|
||||
USBBufferInit(&g_sRxBuffer);
|
||||
|
@ -377,7 +377,7 @@ static void UsbReceivePipeBulkOUT(blt_int8u *data, blt_int32u len)
|
|||
****************************************************************************************/
|
||||
uint32_t UsbBulkTxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue, void *pvMsgData)
|
||||
{
|
||||
if(ui32Event == USB_EVENT_TX_COMPLETE)
|
||||
if (ui32Event == USB_EVENT_TX_COMPLETE)
|
||||
{
|
||||
/* check if more data is waiting to be transmitted */
|
||||
UsbTransmitPipeBulkIN();
|
||||
|
@ -399,7 +399,7 @@ uint32_t UsbBulkTxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgVa
|
|||
uint32_t UsbBulkRxHandler(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue, void *pvMsgData)
|
||||
{
|
||||
/* which event are we being sent? */
|
||||
switch(ui32Event)
|
||||
switch (ui32Event)
|
||||
{
|
||||
/* we are connected to a host and communication is now possible */
|
||||
case USB_EVENT_CONNECTED:
|
||||
|
@ -504,7 +504,7 @@ static blt_int8u UsbFifoMgrCreate(blt_int8u *buffer, blt_int8u length)
|
|||
pbc->writeptr = buffer;
|
||||
pbc->entries = 0;
|
||||
pbc->startptr = buffer;
|
||||
pbc->endptr = (blt_int8u*)(buffer + length - 1);
|
||||
pbc->endptr = (blt_int8u *)(buffer + length - 1);
|
||||
|
||||
/* return the handle to the successfully created fifo control */
|
||||
return pbc->handle;
|
||||
|
|
|
@ -17,7 +17,7 @@ Note: C++ destructors of global objects are NOT yet supported in the HIWARE Obje
|
|||
/*#define __BANKED_COPY_DOWN : allow to allocate .copy in flash area */
|
||||
#if defined(__BANKED_COPY_DOWN) && (!defined(__HCS12X__) || !defined(__ELF_OBJECT_FILE_FORMAT__))
|
||||
#error /* the __BANKED_COPY_DOWN switch is only supported for the HCS12X with ELF */
|
||||
/* (and not for the HC12, HCS12 or for the HIWARE object file format) */
|
||||
/* (and not for the HC12, HCS12 or for the HIWARE object file format) */
|
||||
#endif
|
||||
|
||||
#include "hidef.h"
|
||||
|
@ -71,8 +71,8 @@ __EXTERN_C void main(void); /* prototype of main function */
|
|||
#pragma DATA_SEG __NEAR_SEG STARTUP_DATA /* _startupData can be accessed using 16 bit accesses. */
|
||||
/* This is needed because it contains the stack top, and without stack, far data cannot be accessed */
|
||||
struct _tagStartup _startupData; /* read-only: */
|
||||
/* _startupData is allocated in ROM and */
|
||||
/* initialized by the linker */
|
||||
/* _startupData is allocated in ROM and */
|
||||
/* initialized by the linker */
|
||||
#pragma DATA_SEG DEFAULT
|
||||
#endif /* __ONLY_INIT_SP */
|
||||
|
||||
|
@ -86,8 +86,8 @@ struct _tagStartup _startupData; /* read-only: */
|
|||
|
||||
/*lint -esym(752,_SET_PAGE) , symbol '_SET_PAGE' is referenced in HLI */
|
||||
__EXTERN_C void _SET_PAGE(void); /* the inline assembler needs a prototype */
|
||||
/* this is a runtime routine with a special */
|
||||
/* calling convention, do not use it in c code! */
|
||||
/* this is a runtime routine with a special */
|
||||
/* calling convention, do not use it in c code! */
|
||||
#else
|
||||
/*lint -e451 default.sgm contains a conditionally compiled CODE_SEG pragma */
|
||||
#include "default.sgm"
|
||||
|
@ -127,193 +127,295 @@ static void __far Init(void)
|
|||
#else
|
||||
static void Init(void)
|
||||
#endif
|
||||
{
|
||||
/* purpose: 1) zero out RAM-areas where data is allocated */
|
||||
/* 2) copy initialization data from ROM to RAM */
|
||||
/* 3) call global constructors in C++ */
|
||||
/* called from: _Startup, LibInits */
|
||||
asm
|
||||
{
|
||||
/* purpose: 1) zero out RAM-areas where data is allocated */
|
||||
/* 2) copy initialization data from ROM to RAM */
|
||||
/* 3) call global constructors in C++ */
|
||||
/* called from: _Startup, LibInits */
|
||||
asm {
|
||||
ZeroOut:
|
||||
ZeroOut:
|
||||
#if defined(__HIWARE_OBJECT_FILE_FORMAT__) && defined(__LARGE__)
|
||||
LDX _startupData.pZeroOut:1 ; in the large memory model in the HIWARE format, pZeroOut is a 24 bit pointer
|
||||
LDX _startupData.pZeroOut:1 ;
|
||||
in the large memory model in the HIWARE format, pZeroOut is a 24 bit pointer
|
||||
#else
|
||||
LDX _startupData.pZeroOut ; *pZeroOut
|
||||
LDX _startupData.pZeroOut ;
|
||||
*pZeroOut
|
||||
#endif
|
||||
LDY _startupData.nofZeroOuts ; nofZeroOuts
|
||||
BEQ CopyDown ; if nothing to zero out
|
||||
LDY _startupData.nofZeroOuts ;
|
||||
nofZeroOuts
|
||||
BEQ CopyDown ;
|
||||
if nothing to zero out
|
||||
|
||||
NextZeroOut: PSHY ; save nofZeroOuts
|
||||
NextZeroOut: PSHY ;
|
||||
save nofZeroOuts
|
||||
#if defined(FAR_DATA)
|
||||
LDAB 1,X+ ; load page of destination address
|
||||
LDY 2,X+ ; load offset of destination address
|
||||
LDAB 1,X+ ;
|
||||
load page of destination address
|
||||
LDY 2,X+ ;
|
||||
load offset of destination address
|
||||
#if defined(__HCS12X__)
|
||||
STAB __GPAGE_ADR__
|
||||
#else /* defined(__HCS12X__) */
|
||||
__PIC_JSR(_SET_PAGE) ; sets the page in the correct page register
|
||||
__PIC_JSR(_SET_PAGE) ;
|
||||
sets the page in the correct page register
|
||||
#endif /* defined(__HCS12X__) */
|
||||
#else /* FAR_DATA */
|
||||
LDY 2,X+ ; start address and advance *pZeroOut (X = X+4)
|
||||
LDY 2,X+ ;
|
||||
start address and advance *pZeroOut(X = X+4)
|
||||
#endif /* FAR_DATA */
|
||||
|
||||
#if defined(__HCS12X__) && defined(FAR_DATA)
|
||||
PSHX
|
||||
LDX 0,X ; byte count
|
||||
LDX 0,X ;
|
||||
byte count
|
||||
#if defined(__OPTIMIZE_FOR_SIZE__)
|
||||
CLRA
|
||||
NextWord: GSTAA 1,Y+ ; clear memory byte
|
||||
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE X, NextWord ; dec byte count
|
||||
NextWord:
|
||||
GSTAA 1,Y+ ;
|
||||
clear memory byte
|
||||
__FEED_COP_IN_HLI() ;
|
||||
feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE X, NextWord ;
|
||||
dec byte count
|
||||
#else
|
||||
LDD #0
|
||||
LSRX
|
||||
BEQ LoopClrW1 ; do we copy more than 1 byte?
|
||||
NextWord: GSTD 2,Y+ ; clear memory word
|
||||
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE X, NextWord ; dec word count
|
||||
BEQ LoopClrW1 ;
|
||||
do we copy more than 1 byte?
|
||||
NextWord: GSTD 2,Y+ ;
|
||||
clear memory word
|
||||
__FEED_COP_IN_HLI() ;
|
||||
feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE X, NextWord ;
|
||||
dec word count
|
||||
LoopClrW1:
|
||||
BCC LastClr ; handle last byte
|
||||
GSTAA 1,Y+ ; handle last byte
|
||||
BCC LastClr ;
|
||||
handle last byte
|
||||
GSTAA 1,Y+ ;
|
||||
handle last byte
|
||||
LastClr:
|
||||
#endif
|
||||
PULX
|
||||
LEAX 2,X
|
||||
#elif defined(__OPTIMIZE_FOR_SIZE__) /* -os, default */
|
||||
LDD 2,X+ ; byte count
|
||||
NextWord: CLR 1,Y+ ; clear memory byte
|
||||
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE D, NextWord ; dec byte count
|
||||
LDD 2,X+ ;
|
||||
byte count
|
||||
NextWord:
|
||||
CLR 1,Y+ ;
|
||||
clear memory byte
|
||||
__FEED_COP_IN_HLI() ;
|
||||
feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE D, NextWord ;
|
||||
dec byte count
|
||||
#else /* __OPTIMIZE_FOR_TIME__ */
|
||||
LDD 2,X+ ; byte count
|
||||
LSRD ; /2 and save bit 0 in the carry
|
||||
BEQ LoopClrW1 ; do we copy more than 1 byte?
|
||||
LDD 2,X+ ;
|
||||
byte count
|
||||
LSRD ;
|
||||
/2 and save bit 0 in the carry
|
||||
BEQ LoopClrW1 ;
|
||||
do we copy more than 1 byte?
|
||||
PSHX
|
||||
LDX #0
|
||||
LoopClrW: STX 2,Y+ ; Word-Clear
|
||||
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
LoopClrW: STX 2,Y+ ;
|
||||
Word-Clear
|
||||
__FEED_COP_IN_HLI() ;
|
||||
feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE D, LoopClrW
|
||||
PULX
|
||||
LoopClrW1:
|
||||
BCC LastClr ; handle last byte
|
||||
BCC LastClr ;
|
||||
handle last byte
|
||||
CLR 1,Y+
|
||||
LastClr:
|
||||
#endif /* __OPTIMIZE_FOR_SIZE__/__OPTIMIZE_FOR_TIME__ */
|
||||
PULY ; restore nofZeroOuts
|
||||
DEY ; dec nofZeroOuts
|
||||
PULY ;
|
||||
restore nofZeroOuts
|
||||
DEY ;
|
||||
dec nofZeroOuts
|
||||
BNE NextZeroOut
|
||||
CopyDown:
|
||||
#if defined(__BANKED_COPY_DOWN)
|
||||
LDAA _startupData.toCopyDownBeg:0 ; get PAGE address of .copy section
|
||||
STAA __PPAGE_ADR__ ; set PPAGE address
|
||||
LDX _startupData.toCopyDownBeg:1 ; load address of copy down desc.
|
||||
LDAA _startupData.toCopyDownBeg:0 ;
|
||||
get PAGE address of .copy section
|
||||
STAA __PPAGE_ADR__ ;
|
||||
set PPAGE address
|
||||
LDX _startupData.toCopyDownBeg:1 ;
|
||||
load address of copy down desc.
|
||||
#elif defined(__ELF_OBJECT_FILE_FORMAT__)
|
||||
LDX _startupData.toCopyDownBeg ; load address of copy down desc.
|
||||
LDX _startupData.toCopyDownBeg ;
|
||||
load address of copy down desc.
|
||||
#else
|
||||
LDX _startupData.toCopyDownBeg:2 ; load address of copy down desc.
|
||||
LDX _startupData.toCopyDownBeg:2 ;
|
||||
load address of copy down desc.
|
||||
#endif
|
||||
NextBlock:
|
||||
LDD 2,X+ ; size of init-data -> D
|
||||
BEQ funcInits ; end of copy down desc.
|
||||
LDD 2,X+ ;
|
||||
size of init-data -> D
|
||||
BEQ funcInits ;
|
||||
end of copy down desc.
|
||||
#ifdef FAR_DATA
|
||||
PSHD ; save counter
|
||||
LDAB 1,X+ ; load destination page
|
||||
LDY 2,X+ ; destination address
|
||||
PSHD ;
|
||||
save counter
|
||||
LDAB 1,X+ ;
|
||||
load destination page
|
||||
LDY 2,X+ ;
|
||||
destination address
|
||||
#if defined(__HCS12X__)
|
||||
STAB __GPAGE_ADR__
|
||||
#else /* __HCS12X__ */
|
||||
__PIC_JSR(_SET_PAGE) ; sets the destinations page register
|
||||
__PIC_JSR(_SET_PAGE) ;
|
||||
sets the destinations page register
|
||||
#endif /* __HCS12X__ */
|
||||
PULD ; restore counter
|
||||
PULD ;
|
||||
restore counter
|
||||
#else /* FAR_DATA */
|
||||
LDY 2,X+ ; load destination address
|
||||
LDY 2,X+ ;
|
||||
load destination address
|
||||
#endif /* FAR_DATA */
|
||||
|
||||
#if defined(__HCS12X__) && defined(FAR_DATA)
|
||||
#if defined(__OPTIMIZE_FOR_SIZE__) /* -os, default */
|
||||
Copy: PSHA
|
||||
Copy:
|
||||
PSHA
|
||||
LDAA 1,X+
|
||||
GSTAA 1,Y+ ; move a byte from ROM to the data area
|
||||
GSTAA 1,Y+ ;
|
||||
move a byte from ROM to the data area
|
||||
PULA
|
||||
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE D,Copy ; copy-byte loop
|
||||
__FEED_COP_IN_HLI() ;
|
||||
feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE D,Copy ;
|
||||
copy-byte loop
|
||||
#else
|
||||
LSRD ; /2 and save bit 0 in the carry
|
||||
BEQ Copy1 ; do we copy more than 1 byte?
|
||||
LSRD ;
|
||||
/2 and save bit 0 in the carry
|
||||
BEQ Copy1 ;
|
||||
do we copy more than 1 byte?
|
||||
|
||||
Copy: PSHD
|
||||
Copy: PSHD
|
||||
LDD 2,X+
|
||||
GSTD 2,Y+ ; move a word from ROM to the data area
|
||||
GSTD 2,Y+ ;
|
||||
move a word from ROM to the data area
|
||||
PULD
|
||||
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE D,Copy ; copy-word loop
|
||||
__FEED_COP_IN_HLI() ;
|
||||
feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE D,Copy ;
|
||||
copy-word loop
|
||||
Copy1:
|
||||
BCC NextBlock ; handle last byte?
|
||||
BCC NextBlock ;
|
||||
handle last byte?
|
||||
LDAA 1,X+
|
||||
GSTAA 1,Y+ ; move a byte from ROM to the data area
|
||||
GSTAA 1,Y+ ;
|
||||
move a byte from ROM to the data area
|
||||
#endif
|
||||
#elif defined(__OPTIMIZE_FOR_SIZE__) /* -os, default */
|
||||
Copy: MOVB 1,X+,1,Y+ ; move a byte from ROM to the data area
|
||||
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE D,Copy ; copy-byte loop
|
||||
Copy:
|
||||
MOVB 1,X+,1,Y+ ;
|
||||
move a byte from ROM to the data area
|
||||
__FEED_COP_IN_HLI() ;
|
||||
feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE D,Copy ;
|
||||
copy-byte loop
|
||||
#else /* __OPTIMIZE_FOR_TIME__ */
|
||||
LSRD ; /2 and save bit 0 in the carry
|
||||
BEQ Copy1 ; do we copy more than 1 byte?
|
||||
Copy: MOVW 2,X+,2,Y+ ; move a word from ROM to the data area
|
||||
__FEED_COP_IN_HLI() ; feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE D,Copy ; copy-word loop
|
||||
LSRD ;
|
||||
/2 and save bit 0 in the carry
|
||||
BEQ Copy1 ;
|
||||
do we copy more than 1 byte?
|
||||
Copy: MOVW 2,X+,2,Y+ ;
|
||||
move a word from ROM to the data area
|
||||
__FEED_COP_IN_HLI() ;
|
||||
feed the COP if necessary /*lint !e505 !e522 asm code */
|
||||
DBNE D,Copy ;
|
||||
copy-word loop
|
||||
Copy1:
|
||||
BCC NextBlock ; handle last byte?
|
||||
MOVB 1,X+,1,Y+ ; copy the last byte
|
||||
BCC NextBlock ;
|
||||
handle last byte?
|
||||
MOVB 1,X+,1,Y+ ;
|
||||
copy the last byte
|
||||
#endif /* __OPTIMIZE_FOR_SIZE__/__OPTIMIZE_FOR_TIME__ */
|
||||
BRA NextBlock
|
||||
funcInits: ; call of global construtors is only in c++ necessary
|
||||
funcInits:
|
||||
;
|
||||
call of global construtors is only in c++ necessary
|
||||
#if defined(__cplusplus)
|
||||
#if defined(__ELF_OBJECT_FILE_FORMAT__)
|
||||
#if defined( __BANKED__) || defined(__LARGE__)
|
||||
LDY _startupData.nofInitBodies; load number of cpp.
|
||||
BEQ done ; if cppcount == 0, goto done
|
||||
LDX _startupData.initBodies ; load address of first module to initialize
|
||||
LDY _startupData.nofInitBodies;
|
||||
load number of cpp.
|
||||
BEQ done ;
|
||||
if cppcount == 0, goto done
|
||||
LDX _startupData.initBodies ;
|
||||
load address of first module to initialize
|
||||
nextInit:
|
||||
LEAX 3,X ; increment to next init
|
||||
PSHX ; save address of next function to initialize
|
||||
PSHY ; save cpp counter
|
||||
CALL [-3,X] ; use double indirect call to load the page register also
|
||||
PULY ; restore cpp counter
|
||||
PULX ; restore actual address
|
||||
DEY ; decrement cpp counter
|
||||
LEAX 3,X ;
|
||||
increment to next init
|
||||
PSHX ;
|
||||
save address of next function to initialize
|
||||
PSHY ;
|
||||
save cpp counter
|
||||
CALL [-3,X] ;
|
||||
use double indirect call to load the page register also
|
||||
PULY ;
|
||||
restore cpp counter
|
||||
PULX ;
|
||||
restore actual address
|
||||
DEY ;
|
||||
decrement cpp counter
|
||||
BNE nextInit
|
||||
#else /* defined( __BANKED__) || defined(__LARGE__) */
|
||||
|
||||
LDD _startupData.nofInitBodies; load number of cpp.
|
||||
BEQ done ; if cppcount == 0, goto done
|
||||
LDX _startupData.initBodies ; load address of first module to initialize
|
||||
LDD _startupData.nofInitBodies;
|
||||
load number of cpp.
|
||||
BEQ done ;
|
||||
if cppcount == 0, goto done
|
||||
LDX _startupData.initBodies ;
|
||||
load address of first module to initialize
|
||||
nextInit:
|
||||
LDY 2,X+ ; load address of first module to initialize
|
||||
LDY 2,X+ ;
|
||||
load address of first module to initialize
|
||||
PSHD
|
||||
PSHX ; save actual address
|
||||
JSR 0,Y ; call initialization function
|
||||
PULX ; restore actual address
|
||||
PULD ; restore cpp counter
|
||||
PSHX ;
|
||||
save actual address
|
||||
JSR 0,Y ;
|
||||
call initialization function
|
||||
PULX ;
|
||||
restore actual address
|
||||
PULD ;
|
||||
restore cpp counter
|
||||
DBNE D, nextInit
|
||||
#endif /* defined( __BANKED__) || defined(__LARGE__) */
|
||||
#else /* __ELF_OBJECT_FILE_FORMAT__ */
|
||||
LDX _startupData.mInits ; load address of first module to initialize
|
||||
LDX _startupData.mInits ;
|
||||
load address of first module to initialize
|
||||
#if defined( __BANKED__) || defined(__LARGE__)
|
||||
nextInit: LDY 3,X+ ; load address of initialization function
|
||||
BEQ done ; stop when address == 0
|
||||
; in common environments the offset of a function is never 0, so this test could be avoided
|
||||
nextInit:
|
||||
LDY 3,X+ ;
|
||||
load address of initialization function
|
||||
BEQ done ;
|
||||
stop when address == 0
|
||||
;
|
||||
in common environments the offset of a function is never 0, so this test could be avoided
|
||||
#ifdef __InitFunctionsMayHaveOffset0__
|
||||
BRCLR -1,X, done, 0xff ; stop when address == 0
|
||||
BRCLR -1,X, done, 0xff ;
|
||||
stop when address == 0
|
||||
#endif /* __InitFunctionsMayHaveOffset0__ */
|
||||
PSHX ; save address of next function to initialize
|
||||
CALL [-3,X] ; use double indirect call to load the page register also
|
||||
PSHX ;
|
||||
save address of next function to initialize
|
||||
CALL [-3,X] ;
|
||||
use double indirect call to load the page register also
|
||||
#else /* defined( __BANKED__) || defined(__LARGE__) */
|
||||
nextInit:
|
||||
LDY 2,X+ ; load address of first module to initialize
|
||||
BEQ done ; stop when address of function == 0
|
||||
PSHX ; save actual address
|
||||
JSR 0,Y ; call initialization function
|
||||
LDY 2,X+ ;
|
||||
load address of first module to initialize
|
||||
BEQ done ;
|
||||
stop when address of function == 0
|
||||
PSHX ;
|
||||
save actual address
|
||||
JSR 0,Y ;
|
||||
call initialization function
|
||||
#endif /* defined( __BANKED__) || defined(__LARGE__) */
|
||||
PULX ; restore actual address
|
||||
PULX ;
|
||||
restore actual address
|
||||
BRA nextInit
|
||||
#endif /* __ELF_OBJECT_FILE_FORMAT__ */
|
||||
done:
|
||||
|
@ -330,34 +432,53 @@ static void __far Fini(void)
|
|||
static void Fini(void)
|
||||
#endif
|
||||
{
|
||||
/* purpose: 1) call global destructors in C++ */
|
||||
asm {
|
||||
/* purpose: 1) call global destructors in C++ */
|
||||
asm
|
||||
{
|
||||
#if defined( __BANKED__) || defined(__LARGE__)
|
||||
|
||||
LDY _startupData.nofFiniBodies; load number of cpp.
|
||||
BEQ done ; if cppcount == 0, goto done
|
||||
LDX _startupData.finiBodies ; load address of first module to finalize
|
||||
nextInit2:
|
||||
LEAX 3,X ; increment to next init
|
||||
PSHX ; save address of next function to finalize
|
||||
PSHY ; save cpp counter
|
||||
CALL [-3,X] ; use double indirect call to load the page register also
|
||||
PULY ; restore cpp counter
|
||||
PULX ; restore actual address
|
||||
DEY ; decrement cpp counter
|
||||
LDY _startupData.nofFiniBodies;
|
||||
load number of cpp.
|
||||
BEQ done ;
|
||||
if cppcount == 0, goto done
|
||||
LDX _startupData.finiBodies ;
|
||||
load address of first module to finalize
|
||||
nextInit2:
|
||||
LEAX 3,X ;
|
||||
increment to next init
|
||||
PSHX ;
|
||||
save address of next function to finalize
|
||||
PSHY ;
|
||||
save cpp counter
|
||||
CALL [-3,X] ;
|
||||
use double indirect call to load the page register also
|
||||
PULY ;
|
||||
restore cpp counter
|
||||
PULX ;
|
||||
restore actual address
|
||||
DEY ;
|
||||
decrement cpp counter
|
||||
BNE nextInit2
|
||||
#else /* defined( __BANKED__) || defined(__LARGE__) */
|
||||
|
||||
LDD _startupData.nofFiniBodies; load number of cpp.
|
||||
BEQ done ; if cppcount == 0, goto done
|
||||
LDX _startupData.finiBodies ; load address of first module to finalize
|
||||
nextInit2:
|
||||
LDY 2,X+ ; load address of first module to finalize
|
||||
LDD _startupData.nofFiniBodies;
|
||||
load number of cpp.
|
||||
BEQ done ;
|
||||
if cppcount == 0, goto done
|
||||
LDX _startupData.finiBodies ;
|
||||
load address of first module to finalize
|
||||
nextInit2:
|
||||
LDY 2,X+ ;
|
||||
load address of first module to finalize
|
||||
PSHD
|
||||
PSHX ; save actual address
|
||||
JSR 0,Y ; call finalize function
|
||||
PULX ; restore actual address
|
||||
PULD ; restore cpp counter
|
||||
PSHX ;
|
||||
save actual address
|
||||
JSR 0,Y ;
|
||||
call finalize function
|
||||
PULX ;
|
||||
restore actual address
|
||||
PULD ;
|
||||
restore cpp counter
|
||||
DBNE D, nextInit2
|
||||
#endif /* defined(__BANKED__) || defined(__LARGE__) */
|
||||
done:;
|
||||
|
@ -390,11 +511,13 @@ done:;
|
|||
/* the reset vector must be set so that the application has a defined entry point */
|
||||
|
||||
#if defined(__SET_RESET_VECTOR__)
|
||||
__EXTERN_C void __interrupt 0 _Startup(void) {
|
||||
__EXTERN_C void __interrupt 0 _Startup(void)
|
||||
{
|
||||
#else
|
||||
__EXTERN_C void _Startup(void) {
|
||||
__EXTERN_C void _Startup(void)
|
||||
{
|
||||
#endif
|
||||
/* purpose: 1) initialize the stack
|
||||
/* purpose: 1) initialize the stack
|
||||
2) initialize the RAM, copy down init data etc (Init)
|
||||
3) call main;
|
||||
parameters: NONE
|
||||
|
|
|
@ -107,7 +107,7 @@ void Vector0_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (0 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (0 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -132,7 +132,7 @@ void Vector1_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (1 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (1 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -157,7 +157,7 @@ void Vector2_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (2 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (2 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -182,7 +182,7 @@ void Vector3_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (3 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (3 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -207,7 +207,7 @@ void Vector4_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (4 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (4 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -232,7 +232,7 @@ void Vector5_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (5 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (5 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -257,7 +257,7 @@ void Vector6_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (6 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (6 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -282,7 +282,7 @@ void Vector7_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (7 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (7 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -307,7 +307,7 @@ void Vector8_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (8 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (8 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -332,7 +332,7 @@ void Vector9_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (9 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (9 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -357,7 +357,7 @@ void Vector10_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (10 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (10 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -382,7 +382,7 @@ void Vector11_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (11 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (11 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -407,7 +407,7 @@ void Vector12_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (12 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (12 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -432,7 +432,7 @@ void Vector13_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (13 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (13 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -457,7 +457,7 @@ void Vector14_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (14 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (14 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -482,7 +482,7 @@ void Vector15_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (15 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (15 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -507,7 +507,7 @@ void Vector16_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (16 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (16 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -532,7 +532,7 @@ void Vector17_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (17 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (17 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -557,7 +557,7 @@ void Vector18_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (18 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (18 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -582,7 +582,7 @@ void Vector19_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (19 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (19 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -607,7 +607,7 @@ void Vector20_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (20 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (20 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -632,7 +632,7 @@ void Vector21_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (21 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (21 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -657,7 +657,7 @@ void Vector22_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (22 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (22 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -682,7 +682,7 @@ void Vector23_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (23 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (23 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -707,7 +707,7 @@ void Vector24_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (24 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (24 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -732,7 +732,7 @@ void Vector25_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (25 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (25 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -757,7 +757,7 @@ void Vector26_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (26 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (26 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -782,7 +782,7 @@ void Vector27_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (27 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (27 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -807,7 +807,7 @@ void Vector28_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (28 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (28 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -832,7 +832,7 @@ void Vector29_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (29 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (29 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -857,7 +857,7 @@ void Vector30_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (30 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (30 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -882,7 +882,7 @@ void Vector31_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (31 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (31 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -908,7 +908,7 @@ void Vector32_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (32 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (32 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -933,7 +933,7 @@ void Vector33_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (33 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (33 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -958,7 +958,7 @@ void Vector34_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (34 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (34 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -983,7 +983,7 @@ void Vector35_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (35 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (35 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1008,7 +1008,7 @@ void Vector36_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (36 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (36 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1033,7 +1033,7 @@ void Vector37_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (37 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (37 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1058,7 +1058,7 @@ void Vector38_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (38 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (38 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1083,7 +1083,7 @@ void Vector39_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (39 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (39 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1108,7 +1108,7 @@ void Vector40_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (40 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (40 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1133,7 +1133,7 @@ void Vector41_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (41 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (41 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1158,7 +1158,7 @@ void Vector42_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (42 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (42 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1183,7 +1183,7 @@ void Vector43_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (43 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (43 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1208,7 +1208,7 @@ void Vector44_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (44 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (44 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1233,7 +1233,7 @@ void Vector45_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (45 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (45 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1258,7 +1258,7 @@ void Vector46_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (46 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (46 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1283,7 +1283,7 @@ void Vector47_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (47 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (47 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1308,7 +1308,7 @@ void Vector48_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (48 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (48 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1333,7 +1333,7 @@ void Vector49_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (49 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (49 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1358,7 +1358,7 @@ void Vector50_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (50 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (50 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1383,7 +1383,7 @@ void Vector51_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (51 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (51 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1408,7 +1408,7 @@ void Vector52_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (52 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (52 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1433,7 +1433,7 @@ void Vector53_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (53 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (53 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1458,7 +1458,7 @@ void Vector54_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (54 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (54 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1483,7 +1483,7 @@ void Vector55_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (55 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (55 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1508,7 +1508,7 @@ void Vector56_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (56 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (56 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1533,7 +1533,7 @@ void Vector57_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (57 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (57 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1558,7 +1558,7 @@ void Vector58_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (58 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (58 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1583,7 +1583,7 @@ void Vector59_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (59 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (59 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1608,7 +1608,7 @@ void Vector60_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (60 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (60 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1633,7 +1633,7 @@ void Vector61_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (61 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (61 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
@ -1658,7 +1658,7 @@ void Vector62_handler(void)
|
|||
asm
|
||||
{
|
||||
/* Load the address of the user program's ISR into X. */
|
||||
LDX (VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (62 * 2))
|
||||
LDX(VCT_USER_PROGRAM_VECTOR_TABLE_STARTADDR + (62 * 2))
|
||||
/* Jump there. It is important to use the JMP instruction here as opposed to other
|
||||
* branch instruction, because the JMP instruction does not modify the stack by
|
||||
* saving a return address for example.
|
||||
|
|
|
@ -187,7 +187,8 @@ static blt_bool CanGetSpeedConfig(blt_int16u baud, blt_int8u *btr0, blt_int8u *b
|
|||
* with a sample point between 68..78%.
|
||||
*/
|
||||
static const tCanBusTiming canTiming[] =
|
||||
{ /* TQ | TSEG1 | TSEG2 | SP */
|
||||
{
|
||||
/* TQ | TSEG1 | TSEG2 | SP */
|
||||
/* ------------------------- */
|
||||
{ 5, 2 }, /* 8 | 5 | 2 | 75% */
|
||||
{ 6, 2 }, /* 9 | 6 | 2 | 78% */
|
||||
|
@ -370,13 +371,13 @@ blt_bool CanReceivePacket(blt_int8u *data)
|
|||
if ((CAN->rxSlot.idr[1] & IDE_BIT) == 0)
|
||||
{
|
||||
/* 11-bit id */
|
||||
rxMsgId = (*(blt_int16u*)(&CAN->rxSlot.idr[0])) >> 5;
|
||||
rxMsgId = (*(blt_int16u *)(&CAN->rxSlot.idr[0])) >> 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 29-bit id */
|
||||
rxMsgId = (blt_int32u)(((*(blt_int32u*)(&CAN->rxSlot.idr[0])) & 0x0007ffff) >> 1) |
|
||||
(blt_int32u)(((*(blt_int32u*)(&CAN->rxSlot.idr[0])) & 0xffe00000) >> 3);
|
||||
rxMsgId = (blt_int32u)(((*(blt_int32u *)(&CAN->rxSlot.idr[0])) & 0x0007ffff) >> 1) |
|
||||
(blt_int32u)(((*(blt_int32u *)(&CAN->rxSlot.idr[0])) & 0xffe00000) >> 3);
|
||||
}
|
||||
/* is this the packet identifier? */
|
||||
if (rxMsgId == BOOT_COM_CAN_RX_MSG_ID)
|
||||
|
@ -421,7 +422,7 @@ static blt_bool CanGetSpeedConfig(blt_int16u baud, blt_int8u *btr0, blt_int8u *b
|
|||
prescaler = (blt_int8u)(BOOT_CPU_XTAL_SPEED_KHZ/(baud*(canTiming[cnt].tseg1+canTiming[cnt].tseg2+1)));
|
||||
|
||||
/* make sure the prescaler is valid */
|
||||
if ( (prescaler > 0) && (prescaler <= 64) )
|
||||
if ((prescaler > 0) && (prescaler <= 64))
|
||||
{
|
||||
/* store the MSCAN bustiming register values */
|
||||
*btr0 = prescaler - 1;
|
||||
|
|
|
@ -78,25 +78,25 @@ void CpuStartUserProgram(void)
|
|||
/* not a valid user program so it cannot be started */
|
||||
return;
|
||||
}
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
/* invoke callback */
|
||||
if (CpuUserProgramStartHook() == BLT_FALSE)
|
||||
{
|
||||
/* callback requests the user program to not be started */
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
/* release the communication interface */
|
||||
ComFree();
|
||||
#endif
|
||||
#endif
|
||||
/* reset the timer */
|
||||
TimerReset();
|
||||
/* set the address where the bootloader needs to jump to. this is the address of
|
||||
* the last entry in the user program's vector table. this address points to the
|
||||
* user program's reset handler.
|
||||
*/
|
||||
pProgResetHandler = (void(*)(void))(*((blt_int16u*)CPU_USER_PROGRAM_STARTADDR_PTR));
|
||||
pProgResetHandler = (void(*)(void))(*((blt_int16u *)CPU_USER_PROGRAM_STARTADDR_PTR));
|
||||
/* start the user program by activating its reset interrupt service routine */
|
||||
pProgResetHandler();
|
||||
} /*** end of CpuStartUserProgram ***/
|
||||
|
@ -119,7 +119,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
|
|||
to = (blt_int8u *)dest;
|
||||
|
||||
/* copy all bytes from source address to destination address */
|
||||
while(len-- > 0)
|
||||
while (len-- > 0)
|
||||
{
|
||||
/* store byte value from source to destination */
|
||||
*to++ = *from++;
|
||||
|
|
|
@ -139,7 +139,7 @@ typedef volatile struct
|
|||
} tFlashRegs;
|
||||
|
||||
/** \brief Pointer type to flash command execution function. */
|
||||
typedef void (*pFlashExeCmdFct) (void);
|
||||
typedef void (*pFlashExeCmdFct)(void);
|
||||
|
||||
|
||||
/****************************************************************************************
|
||||
|
@ -358,7 +358,7 @@ void FlashInit(void)
|
|||
clockFreq = BOOT_CPU_XTAL_SPEED_KHZ / (prescaler * (1 + cnt));
|
||||
|
||||
/* is this a valid setting? */
|
||||
if ( (clockFreq > 150) && (clockFreq < 200) )
|
||||
if ((clockFreq > 150) && (clockFreq < 200))
|
||||
{
|
||||
/* configure the setting while taking into account the prescaler */
|
||||
if (prescaler == 8)
|
||||
|
@ -397,7 +397,7 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
|
|||
blt_addr last_block_base_addr;
|
||||
|
||||
/* make sure the addresses are within the flash device */
|
||||
if ( (addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS) )
|
||||
if ((addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
|
|||
erase_base_addr = (addr/FLASH_ERASE_BLOCK_SIZE)*FLASH_ERASE_BLOCK_SIZE;
|
||||
|
||||
/* make sure the addresses are within the flash device */
|
||||
if ( (erase_base_addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS) )
|
||||
if ((erase_base_addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
|
|||
total_erase_len = len + (addr - erase_base_addr);
|
||||
|
||||
/* determine the number of blocks to erase */
|
||||
nr_of_erase_blocks = (blt_int16u) (total_erase_len / FLASH_ERASE_BLOCK_SIZE);
|
||||
nr_of_erase_blocks = (blt_int16u)(total_erase_len / FLASH_ERASE_BLOCK_SIZE);
|
||||
if ((total_erase_len % FLASH_ERASE_BLOCK_SIZE) > 0)
|
||||
{
|
||||
nr_of_erase_blocks++;
|
||||
|
@ -535,7 +535,7 @@ blt_bool FlashWriteChecksum(void)
|
|||
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \
|
||||
FLASH_VECTOR_TABLE_CS_OFFSET;
|
||||
return FlashWrite(checksum_address, sizeof(signature_checksum),
|
||||
(blt_int8u*)&signature_checksum);
|
||||
(blt_int8u *)&signature_checksum);
|
||||
} /*** end of FlashWriteChecksum ***/
|
||||
|
||||
|
||||
|
@ -826,7 +826,7 @@ static blt_bool FlashWriteBlock(tFlashBlockInfo *block)
|
|||
for (word_cnt=0; word_cnt<(FLASH_WRITE_BLOCK_SIZE/sizeof(blt_int16u)); word_cnt++)
|
||||
{
|
||||
prog_addr = block->base_addr + (word_cnt * sizeof(blt_int16u));
|
||||
prog_data = *(volatile blt_int16u*)(&block->data[word_cnt * sizeof(blt_int16u)]);
|
||||
prog_data = *(volatile blt_int16u *)(&block->data[word_cnt * sizeof(blt_int16u)]);
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* program the word to flash */
|
||||
|
@ -873,7 +873,7 @@ static blt_int8u FlashGetLinearAddrByte(blt_addr addr)
|
|||
FLASH_PPAGE_REG = FlashGetPhysPage(addr);
|
||||
|
||||
/* read the byte value from the page address */
|
||||
result = *((blt_int8u*)FlashGetPhysAddr(addr));
|
||||
result = *((blt_int8u *)FlashGetPhysAddr(addr));
|
||||
|
||||
/* restore originally selected page */
|
||||
FLASH_PPAGE_REG = oldPage;
|
||||
|
@ -930,7 +930,7 @@ static void FlashExecuteCommand(void)
|
|||
}
|
||||
|
||||
/* init the function pointer */
|
||||
pExecCommandFct = (pFlashExeCmdFct) ((void *)flashExecCmdRam);
|
||||
pExecCommandFct = (pFlashExeCmdFct)((void *)flashExecCmdRam);
|
||||
/* call the command execution function */
|
||||
pExecCommandFct();
|
||||
} /*** end of FlashExecuteCommand ***/
|
||||
|
@ -973,7 +973,7 @@ static blt_bool FlashOperate(blt_int8u cmd, blt_addr addr, blt_int16u data)
|
|||
if ((FLASH->fstat & CBEIF_BIT) == CBEIF_BIT)
|
||||
{
|
||||
/* write data value to the physical address to operate on */
|
||||
*((blt_int16u*)FlashGetPhysAddr(addr)) = data;
|
||||
*((blt_int16u *)FlashGetPhysAddr(addr)) = data;
|
||||
/* write the command */
|
||||
FLASH->fcmd = cmd;
|
||||
/* launch the actual command */
|
||||
|
|
|
@ -146,7 +146,7 @@ typedef volatile struct
|
|||
} tFlashRegs;
|
||||
|
||||
/** \brief Pointer type to flash command execution function. */
|
||||
typedef void (*pFlashExeCmdFct) (void);
|
||||
typedef void (*pFlashExeCmdFct)(void);
|
||||
|
||||
/** \brief Mapping table for finding the corect flash clock divider prescaler. */
|
||||
typedef struct
|
||||
|
@ -378,8 +378,8 @@ void FlashInit(void)
|
|||
/* try to find correct flash clock divider setting using the lookup table */
|
||||
for (cnt=0; cnt<(sizeof(flashFDIVlookup)/sizeof(flashFDIVlookup[0])); cnt++)
|
||||
{
|
||||
if ( (BOOT_CPU_SYSTEM_SPEED_KHZ > flashFDIVlookup[cnt].sysclock_min) &&
|
||||
(BOOT_CPU_SYSTEM_SPEED_KHZ <= flashFDIVlookup[cnt].sysclock_max) )
|
||||
if ((BOOT_CPU_SYSTEM_SPEED_KHZ > flashFDIVlookup[cnt].sysclock_min) &&
|
||||
(BOOT_CPU_SYSTEM_SPEED_KHZ <= flashFDIVlookup[cnt].sysclock_max))
|
||||
{
|
||||
/* matching configuration found in the lookup table so store it */
|
||||
fdiv_bits = flashFDIVlookup[cnt].prescaler;
|
||||
|
@ -392,7 +392,7 @@ void FlashInit(void)
|
|||
ASSERT_RT(fdiv_bits != FLASH_FDIV_INVALID);
|
||||
|
||||
/* wait until all flash commands are finished */
|
||||
while((FLASH->fstat & CCIF_BIT) == 0)
|
||||
while ((FLASH->fstat & CCIF_BIT) == 0)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
|
|||
blt_addr last_block_base_addr;
|
||||
|
||||
/* make sure the addresses are within the flash device */
|
||||
if ( (addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS) )
|
||||
if ((addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
|
|||
erase_base_addr = (addr/FLASH_ERASE_BLOCK_SIZE)*FLASH_ERASE_BLOCK_SIZE;
|
||||
|
||||
/* make sure the addresses are within the flash device */
|
||||
if ( (erase_base_addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS) )
|
||||
if ((erase_base_addr < FLASH_START_ADDRESS) || ((addr+len-1) > FLASH_END_ADDRESS))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -482,7 +482,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
|
|||
total_erase_len = len + (addr - erase_base_addr);
|
||||
|
||||
/* determine the number of blocks to erase */
|
||||
nr_of_erase_blocks = (blt_int16u) (total_erase_len / FLASH_ERASE_BLOCK_SIZE);
|
||||
nr_of_erase_blocks = (blt_int16u)(total_erase_len / FLASH_ERASE_BLOCK_SIZE);
|
||||
if ((total_erase_len % FLASH_ERASE_BLOCK_SIZE) > 0)
|
||||
{
|
||||
nr_of_erase_blocks++;
|
||||
|
@ -568,7 +568,7 @@ blt_bool FlashWriteChecksum(void)
|
|||
flashLayout[FLASH_LAST_SECTOR_IDX].sector_size - \
|
||||
FLASH_VECTOR_TABLE_CS_OFFSET;
|
||||
return FlashWrite(checksum_address, sizeof(signature_checksum),
|
||||
(blt_int8u*)&signature_checksum);
|
||||
(blt_int8u *)&signature_checksum);
|
||||
} /*** end of FlashWriteChecksum ***/
|
||||
|
||||
|
||||
|
@ -896,7 +896,7 @@ static blt_int8u FlashGetGlobalAddrByte(blt_addr addr)
|
|||
FLASH_PPAGE_REG = FlashGetPhysPage(addr);
|
||||
|
||||
/* read the byte value from the page address */
|
||||
result = *((blt_int8u*)FlashGetPhysAddr(addr));
|
||||
result = *((blt_int8u *)FlashGetPhysAddr(addr));
|
||||
|
||||
/* restore originally selected page */
|
||||
FLASH_PPAGE_REG = oldPage;
|
||||
|
@ -953,7 +953,7 @@ static void FlashExecuteCommand(void)
|
|||
}
|
||||
|
||||
/* init the function pointer */
|
||||
pExecCommandFct = (pFlashExeCmdFct) ((void *)flashExecCmdRam);
|
||||
pExecCommandFct = (pFlashExeCmdFct)((void *)flashExecCmdRam);
|
||||
/* call the command execution function */
|
||||
pExecCommandFct();
|
||||
} /*** end of FlashExecuteCommand ***/
|
||||
|
|
|
@ -231,7 +231,7 @@ blt_bool UartReceivePacket(blt_int8u *data)
|
|||
static blt_bool UartReceiveByte(blt_int8u *data)
|
||||
{
|
||||
/* check if a new byte was received by means of the RDRF-bit */
|
||||
if((UART->scisr1 & RDRF_BIT) != 0)
|
||||
if ((UART->scisr1 & RDRF_BIT) != 0)
|
||||
{
|
||||
/* store the received byte */
|
||||
data[0] = UART->scidrl;
|
||||
|
@ -260,7 +260,7 @@ static blt_bool UartTransmitByte(blt_int8u data)
|
|||
/* write byte to transmit holding register */
|
||||
UART->scidrl = data;
|
||||
/* wait for tx holding register to be empty */
|
||||
while((UART->scisr1 & TDRE_BIT) == 0)
|
||||
while ((UART->scisr1 & TDRE_BIT) == 0)
|
||||
{
|
||||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
|
|
|
@ -94,7 +94,7 @@ static void CpuWriteWDTCON0(blt_int32u value)
|
|||
/* set HWPW1 = 1111b */
|
||||
dummy |= 0x000000F0;
|
||||
/* set HWPW0 = WDTDR */
|
||||
if(WDT_CON1.bits.DR)
|
||||
if (WDT_CON1.bits.DR)
|
||||
{
|
||||
dummy |= 0x00000008;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ static void CpuWriteWDTCON0(blt_int32u value)
|
|||
dummy &= ~0x00000008;
|
||||
}
|
||||
/* set HWPW0 = WDTIR */
|
||||
if(WDT_CON1.bits.IR)
|
||||
if (WDT_CON1.bits.IR)
|
||||
{
|
||||
dummy |= 0x00000004;
|
||||
}
|
||||
|
|
|
@ -74,25 +74,25 @@ void CpuStartUserProgram(void)
|
|||
/* not a valid user program so it cannot be started */
|
||||
return;
|
||||
}
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
#if (BOOT_CPU_USER_PROGRAM_START_HOOK > 0)
|
||||
/* invoke callback */
|
||||
if (CpuUserProgramStartHook() == BLT_FALSE)
|
||||
{
|
||||
/* callback requests the user program to not be started */
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
/* release the communication interface */
|
||||
ComFree();
|
||||
#endif
|
||||
#endif
|
||||
/* reset the timer */
|
||||
TimerReset();
|
||||
/* set the address where the bootloader needs to jump to. the user program entry,
|
||||
* typically called _start, is expected to be located at the start of the user program
|
||||
* flash.
|
||||
*/
|
||||
pProgResetHandler = (void(*)(void))((blt_addr*)CPU_USER_PROGRAM_STARTADDR_PTR);
|
||||
pProgResetHandler = (void(*)(void))((blt_addr *)CPU_USER_PROGRAM_STARTADDR_PTR);
|
||||
/* start the user program by activating its reset interrupt service routine */
|
||||
pProgResetHandler();
|
||||
} /*** end of CpuStartUserProgram ***/
|
||||
|
@ -115,7 +115,7 @@ void CpuMemCopy(blt_addr dest, blt_addr src, blt_int16u len)
|
|||
to = (blt_int8u *)dest;
|
||||
|
||||
/* copy all bytes from source address to destination address */
|
||||
while(len-- > 0)
|
||||
while (len-- > 0)
|
||||
{
|
||||
/* store byte value from source to destination */
|
||||
*to++ = *from++;
|
||||
|
|
|
@ -243,8 +243,8 @@ blt_bool FlashWrite(blt_addr addr, blt_int32u len, blt_int8u *data)
|
|||
blt_addr base_addr;
|
||||
|
||||
/* make sure the addresses are within the flash device */
|
||||
if ( (FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR) )
|
||||
if ((FlashGetSector(addr) == FLASH_INVALID_SECTOR) || \
|
||||
(FlashGetSector(addr+len-1) == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ blt_bool FlashErase(blt_addr addr, blt_int32u len)
|
|||
first_sector = FlashGetSector(addr);
|
||||
last_sector = FlashGetSector(addr+len-1);
|
||||
/* check them */
|
||||
if ( (first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR) )
|
||||
if ((first_sector == FLASH_INVALID_SECTOR) || (last_sector == FLASH_INVALID_SECTOR))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -338,13 +338,13 @@ blt_bool FlashWriteChecksum(void)
|
|||
*/
|
||||
for (wordIdx = 0; wordIdx < FLASH_CS_RANGE_TOTAL_WORDS; wordIdx++)
|
||||
{
|
||||
signature_checksum += *((blt_int32u*)(&bootBlockInfo.data[(wordIdx*4)+FLASH_CS_RANGE_START_OFFSET]));
|
||||
signature_checksum += *((blt_int32u *)(&bootBlockInfo.data[(wordIdx*4)+FLASH_CS_RANGE_START_OFFSET]));
|
||||
}
|
||||
signature_checksum = ~signature_checksum; /* one's complement */
|
||||
|
||||
/* write the checksum */
|
||||
return FlashWrite(flashLayout[0].sector_start+FLASH_CS_OFFSET,
|
||||
sizeof(blt_addr), (blt_int8u*)&signature_checksum);
|
||||
sizeof(blt_addr), (blt_int8u *)&signature_checksum);
|
||||
} /*** end of FlashWriteChecksum ***/
|
||||
|
||||
|
||||
|
@ -363,14 +363,14 @@ blt_bool FlashVerifyChecksum(void)
|
|||
/* compute the checksum by reading it from flash */
|
||||
for (wordIdx = 0; wordIdx < FLASH_CS_RANGE_TOTAL_WORDS; wordIdx++)
|
||||
{
|
||||
signature_checksum += *((blt_int32u*)(flashLayout[0].sector_start + (wordIdx*4) + FLASH_CS_RANGE_START_OFFSET));
|
||||
signature_checksum += *((blt_int32u *)(flashLayout[0].sector_start + (wordIdx*4) + FLASH_CS_RANGE_START_OFFSET));
|
||||
}
|
||||
signature_checksum = ~signature_checksum; /* one's complement */
|
||||
|
||||
/* read the checksum value from flash that was writtin by the bootloader at the end
|
||||
* of the last firmware update
|
||||
*/
|
||||
signature_checksum_rom = *((blt_int32u*)(flashLayout[0].sector_start + FLASH_CS_OFFSET));
|
||||
signature_checksum_rom = *((blt_int32u *)(flashLayout[0].sector_start + FLASH_CS_OFFSET));
|
||||
/* verify that they are both the same */
|
||||
if (signature_checksum == signature_checksum_rom)
|
||||
{
|
||||
|
@ -618,8 +618,8 @@ static blt_bool FlashEraseSectors(blt_int8u first_sector, blt_int8u last_sector)
|
|||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
if ( (first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num) )
|
||||
if ((first_sector < flashLayout[0].sector_num) || \
|
||||
(last_sector > flashLayout[FLASH_TOTAL_SECTORS-1].sector_num))
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -659,9 +659,9 @@ static blt_int8u FlashGetSector(blt_addr address)
|
|||
/* keep the watchdog happy */
|
||||
CopService();
|
||||
/* is the address in this sector? */
|
||||
if ( (address >= flashLayout[sectorIdx].sector_start) && \
|
||||
if ((address >= flashLayout[sectorIdx].sector_start) && \
|
||||
(address < (flashLayout[sectorIdx].sector_start + \
|
||||
flashLayout[sectorIdx].sector_size)) )
|
||||
flashLayout[sectorIdx].sector_size)))
|
||||
{
|
||||
/* return the sector number */
|
||||
return flashLayout[sectorIdx].sector_num;
|
||||
|
@ -756,7 +756,7 @@ static blt_bool FlashTricoreProgramPage(blt_addr start_addr, blt_int8u *data)
|
|||
/* perform DSYNC */
|
||||
CpuSetDSYNC();
|
||||
/* wait until FSR.xFPAGE = '1' */
|
||||
while(pflashFSR->bits.PFPAGE != 1)
|
||||
while (pflashFSR->bits.PFPAGE != 1)
|
||||
{
|
||||
/* fail if FSR.SQER = '1' */
|
||||
if (pflashFSR->bits.SQER == 1)
|
||||
|
@ -790,7 +790,7 @@ static blt_bool FlashTricoreProgramPage(blt_addr start_addr, blt_int8u *data)
|
|||
/* perform DSYNC */
|
||||
CpuSetDSYNC();
|
||||
/* wait until FSR.PROG = '1' */
|
||||
while(pflashFSR->bits.PROG != 1)
|
||||
while (pflashFSR->bits.PROG != 1)
|
||||
{
|
||||
/* fail if FSR.SQER = '1' */
|
||||
if (pflashFSR->bits.SQER == 1)
|
||||
|
@ -806,7 +806,7 @@ static blt_bool FlashTricoreProgramPage(blt_addr start_addr, blt_int8u *data)
|
|||
CopService();
|
||||
}
|
||||
/* wait until FSR.xBUSY = '0' */
|
||||
while(pflashFSR->bits.PBUSY == 1)
|
||||
while (pflashFSR->bits.PBUSY == 1)
|
||||
{
|
||||
/* check flag FSR.xFOPER for ‘1’ as abort criterion to protect against hardware
|
||||
* failures causing BUSY to stay '1'
|
||||
|
@ -829,7 +829,7 @@ static blt_bool FlashTricoreProgramPage(blt_addr start_addr, blt_int8u *data)
|
|||
return BLT_FALSE;
|
||||
}
|
||||
/* evaluate FSR.xDBER */
|
||||
if(pflashFSR->bits.PFDBER != 0)
|
||||
if (pflashFSR->bits.PFDBER != 0)
|
||||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
|
@ -886,7 +886,7 @@ static blt_bool FlashTricoreEraseSector(blt_addr start_addr)
|
|||
/* perform DSYNC */
|
||||
CpuSetDSYNC();
|
||||
/* wait until FSR.ERASE = '1' */
|
||||
while(pflashFSR->bits.ERASE != 1)
|
||||
while (pflashFSR->bits.ERASE != 1)
|
||||
{
|
||||
/* fail if FSR.SQER = '1' */
|
||||
if (pflashFSR->bits.SQER == 1)
|
||||
|
@ -902,7 +902,7 @@ static blt_bool FlashTricoreEraseSector(blt_addr start_addr)
|
|||
CopService();
|
||||
}
|
||||
/* wait until FSR.xBUSY = '0' */
|
||||
while(pflashFSR->bits.PBUSY == 1)
|
||||
while (pflashFSR->bits.PBUSY == 1)
|
||||
{
|
||||
/* check flag FSR.xFOPER for ‘1’ as abort criterion to protect against hardware
|
||||
* failures causing BUSY to stay '1'
|
||||
|
|
|
@ -270,7 +270,7 @@ static blt_bool UartTransmitByte(blt_int8u data)
|
|||
/* write byte to transmit buffer register */
|
||||
UARTx->TBUF.reg = data;
|
||||
/* wait for transmit buffer register to be empty */
|
||||
while(UARTx->TBSRC.bits.SRR == 0)
|
||||
while (UARTx->TBSRC.bits.SRR == 0)
|
||||
{
|
||||
CopService();
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ void AssertFailure(blt_char *file, blt_int32u line)
|
|||
assert_failure_file = file;
|
||||
assert_failure_line = line;
|
||||
/* hang the software so that it requires a hard reset */
|
||||
for(;;)
|
||||
for (;;)
|
||||
{
|
||||
/* keep servicing the watchdog so that this one does not cause a reset */
|
||||
CopService();
|
||||
|
|
|
@ -40,15 +40,15 @@
|
|||
* for runtime assertions.
|
||||
*/
|
||||
#ifdef NDEBUG
|
||||
#define ASSERT_CT(cond) ((void)0)
|
||||
#define ASSERT_RT(cond) ((void)0)
|
||||
#define ASSERT_CT(cond) ((void)0)
|
||||
#define ASSERT_RT(cond) ((void)0)
|
||||
#else
|
||||
#define ASSERT_CONCAT_(a, b) a##b
|
||||
#define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b)
|
||||
/** \brief Macro for assertions that can be performed at compile time. */
|
||||
#define ASSERT_CT(cond) enum { ASSERT_CONCAT(assert_error_on_line_, __LINE__) = 1/(!!(cond)) }
|
||||
/** \brief Macro for assertions that can only be performed at run time. */
|
||||
#define ASSERT_RT(cond) \
|
||||
#define ASSERT_CONCAT_(a, b) a##b
|
||||
#define ASSERT_CONCAT(a, b) ASSERT_CONCAT_(a, b)
|
||||
/** \brief Macro for assertions that can be performed at compile time. */
|
||||
#define ASSERT_CT(cond) enum { ASSERT_CONCAT(assert_error_on_line_, __LINE__) = 1/(!!(cond)) }
|
||||
/** \brief Macro for assertions that can only be performed at run time. */
|
||||
#define ASSERT_RT(cond) \
|
||||
if (cond) \
|
||||
{ ; } \
|
||||
else \
|
||||
|
|
|
@ -41,8 +41,8 @@
|
|||
* Macro definitions
|
||||
****************************************************************************************/
|
||||
#if (BOOT_BACKDOOR_HOOKS_ENABLE == 0)
|
||||
#ifndef BACKDOOR_ENTRY_TIMEOUT_MS
|
||||
/** \brief Sets the time in milliseconds that the backdoor is open, but allow an
|
||||
#ifndef BACKDOOR_ENTRY_TIMEOUT_MS
|
||||
/** \brief Sets the time in milliseconds that the backdoor is open, but allow an
|
||||
* override for this time. note that this time should be at least 2.5 times
|
||||
* as long as the time that is configured in Microboot's XCP settings for the
|
||||
* connect command response. This is the last entry on XCP Timeouts tab. By
|
||||
|
@ -54,12 +54,12 @@
|
|||
* BACKDOOR_ENTRY_TIMEOUT_MS to blt_conf.h with your desired backdoor open time
|
||||
* in milliseconds.
|
||||
*/
|
||||
#if (BOOT_COM_NET_ENABLE == 1)
|
||||
#define BACKDOOR_ENTRY_TIMEOUT_MS (750)
|
||||
#else
|
||||
#define BACKDOOR_ENTRY_TIMEOUT_MS (500)
|
||||
#endif
|
||||
#endif
|
||||
#if (BOOT_COM_NET_ENABLE == 1)
|
||||
#define BACKDOOR_ENTRY_TIMEOUT_MS (750)
|
||||
#else
|
||||
#define BACKDOOR_ENTRY_TIMEOUT_MS (500)
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************************
|
||||
|
@ -99,7 +99,7 @@ void BackDoorInit(void)
|
|||
/* this function does not return if a valid user program is present */
|
||||
CpuStartUserProgram();
|
||||
}
|
||||
#if (BOOT_FILE_SYS_ENABLE > 0)
|
||||
#if (BOOT_FILE_SYS_ENABLE > 0)
|
||||
else
|
||||
{
|
||||
/* the backdoor is open so we should check if a update from locally attached storage
|
||||
|
@ -107,7 +107,7 @@ void BackDoorInit(void)
|
|||
*/
|
||||
FileHandleFirmwareUpdateRequest();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
/* open the backdoor after a reset */
|
||||
backdoorOpen = BLT_TRUE;
|
||||
|
@ -129,7 +129,7 @@ void BackDoorInit(void)
|
|||
void BackDoorCheck(void)
|
||||
{
|
||||
#if (BOOT_BACKDOOR_HOOKS_ENABLE == 0)
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
/* check if a connection with the host was already established. in this case the
|
||||
* backdoor stays open anyway, so no need to check if it needs to be closed.
|
||||
*/
|
||||
|
@ -137,8 +137,8 @@ void BackDoorCheck(void)
|
|||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if (BOOT_FILE_SYS_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_FILE_SYS_ENABLE > 0)
|
||||
/* check if the file module is busy, indicating that a firmware update through the
|
||||
* locally attached storage is in progress. in this case the backdoor stays open
|
||||
* anyway, so no need to check if it needs to be closed.
|
||||
|
@ -147,7 +147,7 @@ void BackDoorCheck(void)
|
|||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* when the backdoor is still open, check if it's time to close it */
|
||||
if (backdoorOpen == BLT_TRUE)
|
||||
|
@ -157,13 +157,13 @@ void BackDoorCheck(void)
|
|||
{
|
||||
/* close the backdoor */
|
||||
backdoorOpen = BLT_FALSE;
|
||||
#if (BOOT_FILE_SYS_ENABLE > 0)
|
||||
#if (BOOT_FILE_SYS_ENABLE > 0)
|
||||
/* during the timed backdoor no remote update request was detected. now do one
|
||||
* last check to see if a firmware update from locally attached storage is
|
||||
* pending.
|
||||
*/
|
||||
if (FileHandleFirmwareUpdateRequest() == BLT_FALSE)
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
/* no firmware update requests detected, so attempt to start the user program.
|
||||
* this function does not return if a valid user program is present.
|
||||
|
|
|
@ -50,14 +50,14 @@ void BootInit(void)
|
|||
TimerInit();
|
||||
/* initialize the non-volatile memory driver */
|
||||
NvmInit();
|
||||
#if (BOOT_FILE_SYS_ENABLE > 0)
|
||||
#if (BOOT_FILE_SYS_ENABLE > 0)
|
||||
/* initialize the file system module */
|
||||
FileInit();
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
/* initialize the communication module */
|
||||
ComInit();
|
||||
#endif
|
||||
#endif
|
||||
/* initialize the backdoor entry */
|
||||
BackDoorInit();
|
||||
} /*** end of BootInit ***/
|
||||
|
@ -74,14 +74,14 @@ void BootTask(void)
|
|||
CopService();
|
||||
/* update the millisecond timer */
|
||||
TimerUpdate();
|
||||
#if (BOOT_FILE_SYS_ENABLE > 0)
|
||||
#if (BOOT_FILE_SYS_ENABLE > 0)
|
||||
/* call worker task for updating firmware from locally attached file storage */
|
||||
FileTask();
|
||||
#endif /* BOOT_FILE_SYS_ENABLE > 0 */
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
#endif /* BOOT_FILE_SYS_ENABLE > 0 */
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
/* process possibly pending communication data */
|
||||
ComTask();
|
||||
#endif
|
||||
#endif
|
||||
/* control the backdoor */
|
||||
BackDoorCheck();
|
||||
} /*** end of BootTask ***/
|
||||
|
|
|
@ -36,16 +36,16 @@
|
|||
****************************************************************************************/
|
||||
#include "boot.h" /* bootloader generic header */
|
||||
#if (BOOT_COM_CAN_ENABLE > 0)
|
||||
#include "can.h" /* can driver module */
|
||||
#include "can.h" /* can driver module */
|
||||
#endif
|
||||
#if (BOOT_COM_UART_ENABLE > 0)
|
||||
#include "uart.h" /* uart driver module */
|
||||
#include "uart.h" /* uart driver module */
|
||||
#endif
|
||||
#if (BOOT_COM_USB_ENABLE > 0)
|
||||
#include "usb.h" /* usb driver module */
|
||||
#include "usb.h" /* usb driver module */
|
||||
#endif
|
||||
#if (BOOT_COM_NET_ENABLE > 0)
|
||||
#include "net.h" /* tcp/ip driver module */
|
||||
#include "net.h" /* tcp/ip driver module */
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ blt_bool FileIsIdle(void)
|
|||
****************************************************************************************/
|
||||
blt_bool FileHandleFirmwareUpdateRequest(void)
|
||||
{
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
#if (BOOT_COM_ENABLE > 0)
|
||||
/* make sure that there is no connection with a remote host to prevent two firmware
|
||||
* updates happening at the same time
|
||||
*/
|
||||
|
@ -158,7 +158,7 @@ blt_bool FileHandleFirmwareUpdateRequest(void)
|
|||
{
|
||||
return BLT_FALSE;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* a new firmware update request can only be handled if not already busy with one */
|
||||
if (firmwareUpdateState != FIRMWARE_UPDATE_STATE_IDLE)
|
||||
{
|
||||
|
@ -195,32 +195,32 @@ void FileTask(void)
|
|||
/* ------------------------------- starting ---------------------------------------- */
|
||||
else if (firmwareUpdateState == FIRMWARE_UPDATE_STATE_STARTING)
|
||||
{
|
||||
#if (BOOT_FILE_STARTED_HOOK_ENABLE > 0)
|
||||
#if (BOOT_FILE_STARTED_HOOK_ENABLE > 0)
|
||||
/* inform application about update started event via hook function */
|
||||
FileFirmwareUpdateStartedHook();
|
||||
#endif
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("Firmware update request detected\n\r");
|
||||
FileFirmwareUpdateLogHook("Opening firmware file for reading...");
|
||||
#endif
|
||||
#endif
|
||||
/* attempt to obtain a file object for the firmware file */
|
||||
if (f_open(&fatFsObjects.file, FileGetFirmwareFilenameHook(), FA_OPEN_EXISTING | FA_READ) != FR_OK)
|
||||
{
|
||||
/* can't open file */
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("ERROR\n\r");
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
FileFirmwareUpdateErrorHook(FILE_ERROR_CANNOT_OPEN_FIRMWARE_FILE);
|
||||
#endif
|
||||
#endif
|
||||
/* nothing left to do now */
|
||||
return;
|
||||
}
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("OK\n\r");
|
||||
FileFirmwareUpdateLogHook("Starting the programming sequence\n\r");
|
||||
FileFirmwareUpdateLogHook("Parsing firmware file to obtain erase size...");
|
||||
#endif
|
||||
#endif
|
||||
/* prepare data objects for the erasing state */
|
||||
eraseInfo.start_address = 0;
|
||||
eraseInfo.total_size = 0;
|
||||
|
@ -235,12 +235,12 @@ void FileTask(void)
|
|||
/* check if an error occurred */
|
||||
if (f_error(&fatFsObjects.file) > 0)
|
||||
{
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("ERROR\n\r");
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
FileFirmwareUpdateErrorHook(FILE_ERROR_CANNOT_READ_FROM_FILE);
|
||||
#endif
|
||||
#endif
|
||||
/* close the file */
|
||||
f_close(&fatFsObjects.file);
|
||||
/* cannot continue with firmware update so go back to idle state */
|
||||
|
@ -254,12 +254,12 @@ void FileTask(void)
|
|||
/* check parsing result */
|
||||
if (parse_result == ERROR_SREC_INVALID_CHECKSUM)
|
||||
{
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("ERROR\n\r");
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
FileFirmwareUpdateErrorHook(FILE_ERROR_INVALID_CHECKSUM_IN_FILE);
|
||||
#endif
|
||||
#endif
|
||||
/* close the file */
|
||||
f_close(&fatFsObjects.file);
|
||||
/* cannot continue with firmware update so go back to idle state */
|
||||
|
@ -293,19 +293,19 @@ void FileTask(void)
|
|||
/* rewind the file in preparation for the programming state */
|
||||
if (f_lseek(&fatFsObjects.file, 0) != FR_OK)
|
||||
{
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("ERROR\n\r");
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
FileFirmwareUpdateErrorHook(FILE_ERROR_REWINDING_FILE_READ_POINTER);
|
||||
#endif
|
||||
#endif
|
||||
/* close the file */
|
||||
f_close(&fatFsObjects.file);
|
||||
/* cannot continue with firmware update so go back to idle state */
|
||||
firmwareUpdateState = FIRMWARE_UPDATE_STATE_IDLE;
|
||||
return;
|
||||
}
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("OK\n\r");
|
||||
FileFirmwareUpdateLogHook("Erasing ");
|
||||
/* convert size to string */
|
||||
|
@ -319,25 +319,25 @@ void FileTask(void)
|
|||
FileLibByteToHexString((blt_int8u)eraseInfo.start_address, &loggingStr[6]);
|
||||
FileFirmwareUpdateLogHook(loggingStr);
|
||||
FileFirmwareUpdateLogHook("...");
|
||||
#endif
|
||||
#endif
|
||||
/* still here so we are ready to perform the memory erase operation */
|
||||
if (NvmErase(eraseInfo.start_address, eraseInfo.total_size) == BLT_FALSE)
|
||||
{
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("ERROR\n\r");
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
FileFirmwareUpdateErrorHook(FILE_ERROR_CANNOT_ERASE_MEMORY);
|
||||
#endif
|
||||
#endif
|
||||
/* close the file */
|
||||
f_close(&fatFsObjects.file);
|
||||
/* cannot continue with firmware update so go back to idle state */
|
||||
firmwareUpdateState = FIRMWARE_UPDATE_STATE_IDLE;
|
||||
return;
|
||||
}
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("OK\n\r");
|
||||
#endif
|
||||
#endif
|
||||
/* all okay, then go to programming state */
|
||||
firmwareUpdateState = FIRMWARE_UPDATE_STATE_PROGRAMMING;
|
||||
}
|
||||
|
@ -350,12 +350,12 @@ void FileTask(void)
|
|||
/* check if an error occurred */
|
||||
if (f_error(&fatFsObjects.file) > 0)
|
||||
{
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("Reading line from file...ERROR\n\r");
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
FileFirmwareUpdateErrorHook(FILE_ERROR_CANNOT_READ_FROM_FILE);
|
||||
#endif
|
||||
#endif
|
||||
/* close the file */
|
||||
f_close(&fatFsObjects.file);
|
||||
/* cannot continue with firmware update so go back to idle state */
|
||||
|
@ -369,12 +369,12 @@ void FileTask(void)
|
|||
/* check parsing result */
|
||||
if (parse_result == ERROR_SREC_INVALID_CHECKSUM)
|
||||
{
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("Invalid checksum found...ERROR\n\r");
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
FileFirmwareUpdateErrorHook(FILE_ERROR_INVALID_CHECKSUM_IN_FILE);
|
||||
#endif
|
||||
#endif
|
||||
/* close the file */
|
||||
f_close(&fatFsObjects.file);
|
||||
/* cannot continue with firmware update so go back to idle state */
|
||||
|
@ -385,7 +385,7 @@ void FileTask(void)
|
|||
/* only process parsing results if the line contained address/data info */
|
||||
if (parse_result > 0)
|
||||
{
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("Programming ");
|
||||
/* convert size to string */
|
||||
FileLibLongToIntString(parse_result, loggingStr);
|
||||
|
@ -398,62 +398,62 @@ void FileTask(void)
|
|||
FileLibByteToHexString((blt_int8u)lineParseObject.address, &loggingStr[6]);
|
||||
FileFirmwareUpdateLogHook(loggingStr);
|
||||
FileFirmwareUpdateLogHook("...");
|
||||
#endif
|
||||
#endif
|
||||
/* program the data */
|
||||
if (NvmWrite(lineParseObject.address, parse_result, lineParseObject.data) == BLT_FALSE)
|
||||
{
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("ERROR\n\r");
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
FileFirmwareUpdateErrorHook(FILE_ERROR_CANNOT_PROGRAM_MEMORY);
|
||||
#endif
|
||||
#endif
|
||||
/* close the file */
|
||||
f_close(&fatFsObjects.file);
|
||||
/* cannot continue with firmware update so go back to idle state */
|
||||
firmwareUpdateState = FIRMWARE_UPDATE_STATE_IDLE;
|
||||
return;
|
||||
}
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("OK\n\r");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
/* check if the end of the file was reached */
|
||||
if (f_eof(&fatFsObjects.file) > 0)
|
||||
{
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("Writing program checksum...");
|
||||
#endif
|
||||
#endif
|
||||
/* finish the programming by writing the checksum */
|
||||
if (NvmDone() == BLT_FALSE)
|
||||
{
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("ERROR\n\r");
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE > 0)
|
||||
FileFirmwareUpdateErrorHook(FILE_ERROR_CANNOT_WRITE_CHECKSUM);
|
||||
#endif
|
||||
#endif
|
||||
/* close the file */
|
||||
f_close(&fatFsObjects.file);
|
||||
/* cannot continue with firmware update so go back to idle state */
|
||||
firmwareUpdateState = FIRMWARE_UPDATE_STATE_IDLE;
|
||||
return;
|
||||
}
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("OK\n\r");
|
||||
FileFirmwareUpdateLogHook("Closing firmware file\n\r");
|
||||
#endif
|
||||
#endif
|
||||
/* close the file */
|
||||
f_close(&fatFsObjects.file);
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
#if (BOOT_FILE_LOGGING_ENABLE > 0)
|
||||
FileFirmwareUpdateLogHook("Firmware update successfully completed\n\r");
|
||||
#endif
|
||||
#endif
|
||||
/* all done so transistion back to idle mode */
|
||||
firmwareUpdateState = FIRMWARE_UPDATE_STATE_IDLE;
|
||||
#if (BOOT_FILE_COMPLETED_HOOK_ENABLE > 0)
|
||||
#if (BOOT_FILE_COMPLETED_HOOK_ENABLE > 0)
|
||||
/* inform application about update completed event via hook function */
|
||||
FileFirmwareUpdateCompletedHook();
|
||||
#endif
|
||||
#endif
|
||||
/* attempt to start the user program now that programming is done. note that
|
||||
* a call to CpuReset() won't work correctly here, because if the same firmware
|
||||
* file is still on the locally attached storage, it will just restart the
|
||||
|
@ -474,7 +474,7 @@ void FileTask(void)
|
|||
tSrecLineType FileSrecGetLineType(const blt_char *line)
|
||||
{
|
||||
/* check if the line starts with the 'S' character, followed by a digit */
|
||||
if ( (toupper(line[0]) != 'S') || (isdigit(line[1]) == 0) )
|
||||
if ((toupper(line[0]) != 'S') || (isdigit(line[1]) == 0))
|
||||
{
|
||||
/* not a valid S-Record line type */
|
||||
return LINE_TYPE_UNSUPPORTED;
|
||||
|
@ -784,7 +784,7 @@ static blt_int8u FileLibHexStringToByte(const blt_char *hexstring)
|
|||
/* read out the character */
|
||||
c = toupper(hexstring[counter]);
|
||||
/* check that the character is 0..9 or A..F */
|
||||
if ( (c < '0') || (c > 'F') || ( (c > '9') && (c < 'A') ) )
|
||||
if ((c < '0') || (c > 'F') || ((c > '9') && (c < 'A')))
|
||||
{
|
||||
/* character not valid */
|
||||
return 0;
|
||||
|
|
|
@ -91,15 +91,15 @@ static blt_int32u ARPTimerTimeOut;
|
|||
void NetInit(void)
|
||||
{
|
||||
uip_ipaddr_t ipaddr;
|
||||
#if (BOOT_COM_NET_IPADDR_HOOK_ENABLE > 0)
|
||||
#if (BOOT_COM_NET_IPADDR_HOOK_ENABLE > 0)
|
||||
blt_int8u ipAddrArray[4];
|
||||
#endif
|
||||
#if (BOOT_COM_NET_NETMASK_HOOK_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_COM_NET_NETMASK_HOOK_ENABLE > 0)
|
||||
blt_int8u netMaskArray[4];
|
||||
#endif
|
||||
#if (BOOT_COM_NET_GATEWAY_HOOK_ENABLE > 0)
|
||||
#endif
|
||||
#if (BOOT_COM_NET_GATEWAY_HOOK_ENABLE > 0)
|
||||
blt_int8u gatewayAddrArray[4];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* initialize the network device */
|
||||
netdev_init();
|
||||
|
@ -109,31 +109,31 @@ void NetInit(void)
|
|||
/* initialize the uIP TCP/IP stack. */
|
||||
uip_init();
|
||||
/* set the IP address */
|
||||
#if (BOOT_COM_NET_IPADDR_HOOK_ENABLE > 0)
|
||||
#if (BOOT_COM_NET_IPADDR_HOOK_ENABLE > 0)
|
||||
NetIpAddressHook(ipAddrArray);
|
||||
uip_ipaddr(ipaddr, ipAddrArray[0], ipAddrArray[1], ipAddrArray[2], ipAddrArray[3]);
|
||||
#else
|
||||
#else
|
||||
uip_ipaddr(ipaddr, BOOT_COM_NET_IPADDR0, BOOT_COM_NET_IPADDR1, BOOT_COM_NET_IPADDR2,
|
||||
BOOT_COM_NET_IPADDR3);
|
||||
#endif
|
||||
#endif
|
||||
uip_sethostaddr(ipaddr);
|
||||
/* set the network mask */
|
||||
#if (BOOT_COM_NET_NETMASK_HOOK_ENABLE > 0)
|
||||
#if (BOOT_COM_NET_NETMASK_HOOK_ENABLE > 0)
|
||||
NetNetworkMaskHook(netMaskArray);
|
||||
uip_ipaddr(ipaddr, netMaskArray[0], netMaskArray[1], netMaskArray[2], netMaskArray[3]);
|
||||
#else
|
||||
#else
|
||||
uip_ipaddr(ipaddr, BOOT_COM_NET_NETMASK0, BOOT_COM_NET_NETMASK1, BOOT_COM_NET_NETMASK2,
|
||||
BOOT_COM_NET_NETMASK3);
|
||||
#endif
|
||||
#endif
|
||||
uip_setnetmask(ipaddr);
|
||||
/* set the gateway address */
|
||||
#if (BOOT_COM_NET_GATEWAY_HOOK_ENABLE > 0)
|
||||
#if (BOOT_COM_NET_GATEWAY_HOOK_ENABLE > 0)
|
||||
NetGatewayAddressHook(gatewayAddrArray);
|
||||
uip_ipaddr(ipaddr, gatewayAddrArray[0], gatewayAddrArray[1], gatewayAddrArray[2], gatewayAddrArray[3]);
|
||||
#else
|
||||
#else
|
||||
uip_ipaddr(ipaddr, BOOT_COM_NET_GATEWAY0, BOOT_COM_NET_GATEWAY1, BOOT_COM_NET_GATEWAY2,
|
||||
BOOT_COM_NET_GATEWAY3);
|
||||
#endif
|
||||
#endif
|
||||
uip_setdraddr(ipaddr);
|
||||
/* start listening on the configured port for XCP transfers on TCP/IP */
|
||||
uip_listen(HTONS(BOOT_COM_NET_PORT));
|
||||
|
@ -158,7 +158,7 @@ void NetTransmitPacket(blt_int8u *data, blt_int8u len)
|
|||
s = &(uip_conn->appstate);
|
||||
|
||||
/* add the dto counter first */
|
||||
*(blt_int32u*)&(s->dto_data[0]) = s->dto_counter;
|
||||
*(blt_int32u *)&(s->dto_data[0]) = s->dto_counter;
|
||||
/* copy the actual XCP response */
|
||||
for (cnt=0; cnt<len; cnt++)
|
||||
{
|
||||
|
@ -260,13 +260,13 @@ static void NetServerTask(void)
|
|||
|
||||
/* check for an RX packet and read it. */
|
||||
packetLen = netdev_read();
|
||||
if(packetLen > 0)
|
||||
if (packetLen > 0)
|
||||
{
|
||||
/* set uip_len for uIP stack usage */
|
||||
uip_len = (blt_int16u)packetLen;
|
||||
|
||||
/* process incoming IP packets here. */
|
||||
if(NET_UIP_HEADER_BUF->type == htons(UIP_ETHTYPE_IP))
|
||||
if (NET_UIP_HEADER_BUF->type == htons(UIP_ETHTYPE_IP))
|
||||
{
|
||||
uip_arp_ipin();
|
||||
uip_input();
|
||||
|
@ -274,7 +274,7 @@ static void NetServerTask(void)
|
|||
* should be sent out on the network, the global variable
|
||||
* uip_len is set to a value > 0.
|
||||
*/
|
||||
if(uip_len > 0)
|
||||
if (uip_len > 0)
|
||||
{
|
||||
uip_arp_out();
|
||||
netdev_send();
|
||||
|
@ -282,7 +282,7 @@ static void NetServerTask(void)
|
|||
}
|
||||
}
|
||||
/* process incoming ARP packets here. */
|
||||
else if(NET_UIP_HEADER_BUF->type == htons(UIP_ETHTYPE_ARP))
|
||||
else if (NET_UIP_HEADER_BUF->type == htons(UIP_ETHTYPE_ARP))
|
||||
{
|
||||
uip_arp_arpin();
|
||||
|
||||
|
@ -290,7 +290,7 @@ static void NetServerTask(void)
|
|||
* should be sent out on the network, the global variable
|
||||
* uip_len is set to a value > 0.
|
||||
*/
|
||||
if(uip_len > 0)
|
||||
if (uip_len > 0)
|
||||
{
|
||||
netdev_send();
|
||||
uip_len = 0;
|
||||
|
@ -309,7 +309,7 @@ static void NetServerTask(void)
|
|||
* should be sent out on the network, the global variable
|
||||
* uip_len is set to a value > 0.
|
||||
*/
|
||||
if(uip_len > 0)
|
||||
if (uip_len > 0)
|
||||
{
|
||||
uip_arp_out();
|
||||
netdev_send();
|
||||
|
|
|
@ -111,61 +111,61 @@
|
|||
#endif
|
||||
|
||||
#if (BOOT_COM_CAN_ENABLE > 0)
|
||||
#ifndef BOOT_COM_CAN_BAUDRATE
|
||||
#error "BOOT_COM_CAN_BAUDRATE is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_CAN_BAUDRATE
|
||||
#error "BOOT_COM_CAN_BAUDRATE is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_CAN_BAUDRATE <= 0)
|
||||
#error "BOOT_COM_CAN_BAUDRATE must be > 0"
|
||||
#endif
|
||||
#if (BOOT_COM_CAN_BAUDRATE <= 0)
|
||||
#error "BOOT_COM_CAN_BAUDRATE must be > 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_CAN_TX_MSG_ID
|
||||
#error "BOOT_COM_CAN_TX_MSG_ID is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_CAN_TX_MSG_ID
|
||||
#error "BOOT_COM_CAN_TX_MSG_ID is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_CAN_TX_MSG_ID <= 0)
|
||||
#error "BOOT_COM_CAN_TX_MSG_ID must be > 0"
|
||||
#endif
|
||||
#if (BOOT_COM_CAN_TX_MSG_ID <= 0)
|
||||
#error "BOOT_COM_CAN_TX_MSG_ID must be > 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_CAN_TX_MAX_DATA
|
||||
#error "BOOT_COM_CAN_TX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_CAN_TX_MAX_DATA
|
||||
#error "BOOT_COM_CAN_TX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_CAN_TX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_CAN_TX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
#if (BOOT_COM_CAN_TX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_CAN_TX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_CAN_TX_MAX_DATA > 8)
|
||||
#error "BOOT_COM_CAN_TX_MAX_DATA must be <= 8"
|
||||
#endif
|
||||
#if (BOOT_COM_CAN_TX_MAX_DATA > 8)
|
||||
#error "BOOT_COM_CAN_TX_MAX_DATA must be <= 8"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_CAN_RX_MSG_ID
|
||||
#error "BOOT_COM_CAN_RX_MSG_ID is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_CAN_RX_MSG_ID
|
||||
#error "BOOT_COM_CAN_RX_MSG_ID is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_CAN_RX_MSG_ID <= 0)
|
||||
#error "BOOT_COM_CAN_RX_MSG_ID must be > 0"
|
||||
#endif
|
||||
#if (BOOT_COM_CAN_RX_MSG_ID <= 0)
|
||||
#error "BOOT_COM_CAN_RX_MSG_ID must be > 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_CAN_RX_MAX_DATA
|
||||
#error "BOOT_COM_CAN_RX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_CAN_RX_MAX_DATA
|
||||
#error "BOOT_COM_CAN_RX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_CAN_RX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_CAN_RX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
#if (BOOT_COM_CAN_RX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_CAN_RX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_CAN_RX_MAX_DATA > 8)
|
||||
#error "BOOT_COM_CAN_RX_MAX_DATA must be <= 8"
|
||||
#endif
|
||||
#if (BOOT_COM_CAN_RX_MAX_DATA > 8)
|
||||
#error "BOOT_COM_CAN_RX_MAX_DATA must be <= 8"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_CAN_CHANNEL_INDEX
|
||||
#error "BOOT_COM_CAN_CHANNEL_INDEX is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_CAN_CHANNEL_INDEX
|
||||
#error "BOOT_COM_CAN_CHANNEL_INDEX is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_CAN_CHANNEL_INDEX < 0)
|
||||
#error "BOOT_COM_CAN_CHANNEL_INDEX must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_CAN_CHANNEL_INDEX < 0)
|
||||
#error "BOOT_COM_CAN_CHANNEL_INDEX must be >= 0"
|
||||
#endif
|
||||
#endif /* BOOT_COM_CAN_ENABLE > 0 */
|
||||
|
||||
#ifndef BOOT_COM_UART_ENABLE
|
||||
|
@ -173,45 +173,45 @@
|
|||
#endif
|
||||
|
||||
#if (BOOT_COM_UART_ENABLE > 0)
|
||||
#ifndef BOOT_COM_UART_BAUDRATE
|
||||
#error "BOOT_COM_UART_BAUDRATE is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_UART_BAUDRATE
|
||||
#error "BOOT_COM_UART_BAUDRATE is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_UART_BAUDRATE <= 0)
|
||||
#error "BOOT_COM_UART_BAUDRATE must be > 0"
|
||||
#endif
|
||||
#if (BOOT_COM_UART_BAUDRATE <= 0)
|
||||
#error "BOOT_COM_UART_BAUDRATE must be > 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_UART_TX_MAX_DATA
|
||||
#error "BOOT_COM_UART_TX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_UART_TX_MAX_DATA
|
||||
#error "BOOT_COM_UART_TX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_UART_TX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_UART_TX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
#if (BOOT_COM_UART_TX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_UART_TX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_UART_TX_MAX_DATA > 255)
|
||||
#error "BOOT_COM_UART_TX_MAX_DATA must be <= 255"
|
||||
#endif
|
||||
#if (BOOT_COM_UART_TX_MAX_DATA > 255)
|
||||
#error "BOOT_COM_UART_TX_MAX_DATA must be <= 255"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_UART_RX_MAX_DATA
|
||||
#error "BOOT_COM_UART_RX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_UART_RX_MAX_DATA
|
||||
#error "BOOT_COM_UART_RX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_UART_RX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_UART_RX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
#if (BOOT_COM_UART_RX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_UART_RX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_UART_RX_MAX_DATA > 255)
|
||||
#error "BOOT_COM_UART_RX_MAX_DATA must be <= 255"
|
||||
#endif
|
||||
#if (BOOT_COM_UART_RX_MAX_DATA > 255)
|
||||
#error "BOOT_COM_UART_RX_MAX_DATA must be <= 255"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_UART_CHANNEL_INDEX
|
||||
#error "BOOT_COM_UART_CHANNEL_INDEX is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_UART_CHANNEL_INDEX
|
||||
#error "BOOT_COM_UART_CHANNEL_INDEX is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_UART_CHANNEL_INDEX < 0)
|
||||
#error "BOOT_COM_UART_CHANNEL_INDEX must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_UART_CHANNEL_INDEX < 0)
|
||||
#error "BOOT_COM_UART_CHANNEL_INDEX must be >= 0"
|
||||
#endif
|
||||
#endif /* BOOT_COM_UART_ENABLE > 0 */
|
||||
|
||||
#ifndef BOOT_COM_USB_ENABLE
|
||||
|
@ -219,21 +219,21 @@
|
|||
#endif
|
||||
|
||||
#if (BOOT_COM_USB_ENABLE > 0)
|
||||
#ifndef BOOT_COM_USB_TX_MAX_DATA
|
||||
#error "BOOT_COM_USB_TX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_USB_TX_MAX_DATA
|
||||
#error "BOOT_COM_USB_TX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_USB_TX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_USB_TX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
#if (BOOT_COM_USB_TX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_USB_TX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_USB_RX_MAX_DATA
|
||||
#error "BOOT_COM_USB_RX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_USB_RX_MAX_DATA
|
||||
#error "BOOT_COM_USB_RX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_USB_RX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_USB_RX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
#if (BOOT_COM_USB_RX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_USB_RX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
#endif /* BOOT_COM_USB_ENABLE > 0 */
|
||||
|
||||
|
||||
|
@ -243,137 +243,137 @@
|
|||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_ENABLE > 0)
|
||||
#ifndef BOOT_COM_NET_TX_MAX_DATA
|
||||
#error "BOOT_COM_NET_TX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_TX_MAX_DATA
|
||||
#error "BOOT_COM_NET_TX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_TX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_NET_TX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_TX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_NET_TX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_RX_MAX_DATA
|
||||
#error "BOOT_COM_NET_RX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_RX_MAX_DATA
|
||||
#error "BOOT_COM_NET_RX_MAX_DATA is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_RX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_NET_RX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_RX_MAX_DATA <= 0)
|
||||
#error "BOOT_COM_NET_RX_MAX_DATA must be > 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_IPADDR0
|
||||
#error "BOOT_COM_NET_IPADDR0 is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_IPADDR0
|
||||
#error "BOOT_COM_NET_IPADDR0 is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_IPADDR0 < 0)
|
||||
#error "BOOT_COM_NET_IPADDR0 must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_IPADDR0 < 0)
|
||||
#error "BOOT_COM_NET_IPADDR0 must be >= 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_IPADDR1
|
||||
#error "BOOT_COM_NET_IPADDR1 is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_IPADDR1
|
||||
#error "BOOT_COM_NET_IPADDR1 is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_IPADDR1 < 0)
|
||||
#error "BOOT_COM_NET_IPADDR1 must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_IPADDR1 < 0)
|
||||
#error "BOOT_COM_NET_IPADDR1 must be >= 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_IPADDR2
|
||||
#error "BOOT_COM_NET_IPADDR2 is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_IPADDR2
|
||||
#error "BOOT_COM_NET_IPADDR2 is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_IPADDR2 < 0)
|
||||
#error "BOOT_COM_NET_IPADDR2 must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_IPADDR2 < 0)
|
||||
#error "BOOT_COM_NET_IPADDR2 must be >= 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_IPADDR3
|
||||
#error "BOOT_COM_NET_IPADDR3 is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_IPADDR3
|
||||
#error "BOOT_COM_NET_IPADDR3 is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_IPADDR3 < 0)
|
||||
#error "BOOT_COM_NET_IPADDR3 must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_IPADDR3 < 0)
|
||||
#error "BOOT_COM_NET_IPADDR3 must be >= 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_NETMASK0
|
||||
#error "BOOT_COM_NET_NETMASK0 is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_NETMASK0
|
||||
#error "BOOT_COM_NET_NETMASK0 is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_NETMASK0 < 0)
|
||||
#error "BOOT_COM_NET_NETMASK0 must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_NETMASK0 < 0)
|
||||
#error "BOOT_COM_NET_NETMASK0 must be >= 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_NETMASK1
|
||||
#error "BOOT_COM_NET_NETMASK1 is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_NETMASK1
|
||||
#error "BOOT_COM_NET_NETMASK1 is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_NETMASK1 < 0)
|
||||
#error "BOOT_COM_NET_NETMASK1 must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_NETMASK1 < 0)
|
||||
#error "BOOT_COM_NET_NETMASK1 must be >= 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_NETMASK2
|
||||
#error "BOOT_COM_NET_NETMASK2 is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_NETMASK2
|
||||
#error "BOOT_COM_NET_NETMASK2 is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_NETMASK2 < 0)
|
||||
#error "BOOT_COM_NET_NETMASK2 must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_NETMASK2 < 0)
|
||||
#error "BOOT_COM_NET_NETMASK2 must be >= 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_NETMASK3
|
||||
#error "BOOT_COM_NET_NETMASK3 is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_NETMASK3
|
||||
#error "BOOT_COM_NET_NETMASK3 is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_NETMASK3 < 0)
|
||||
#error "BOOT_COM_NET_NETMASK3 must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_NETMASK3 < 0)
|
||||
#error "BOOT_COM_NET_NETMASK3 must be >= 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_GATEWAY0
|
||||
#error "BOOT_COM_NET_GATEWAY0 is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_GATEWAY0
|
||||
#error "BOOT_COM_NET_GATEWAY0 is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_GATEWAY0 < 0)
|
||||
#error "BOOT_COM_NET_GATEWAY0 must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_GATEWAY0 < 0)
|
||||
#error "BOOT_COM_NET_GATEWAY0 must be >= 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_GATEWAY1
|
||||
#error "BOOT_COM_NET_GATEWAY1 is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_GATEWAY1
|
||||
#error "BOOT_COM_NET_GATEWAY1 is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_GATEWAY1 < 0)
|
||||
#error "BOOT_COM_NET_GATEWAY1 must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_GATEWAY1 < 0)
|
||||
#error "BOOT_COM_NET_GATEWAY1 must be >= 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_GATEWAY2
|
||||
#error "BOOT_COM_NET_GATEWAY2 is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_GATEWAY2
|
||||
#error "BOOT_COM_NET_GATEWAY2 is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_GATEWAY2 < 0)
|
||||
#error "BOOT_COM_NET_GATEWAY2 must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_GATEWAY2 < 0)
|
||||
#error "BOOT_COM_NET_GATEWAY2 must be >= 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_GATEWAY3
|
||||
#error "BOOT_COM_NET_GATEWAY3 is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_GATEWAY3
|
||||
#error "BOOT_COM_NET_GATEWAY3 is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_GATEWAY3 < 0)
|
||||
#error "BOOT_COM_NET_GATEWAY3 must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_GATEWAY3 < 0)
|
||||
#error "BOOT_COM_NET_GATEWAY3 must be >= 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_PORT
|
||||
#error "BOOT_COM_NET_PORT is missing in blt_conf.h"
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_PORT
|
||||
#error "BOOT_COM_NET_PORT is missing in blt_conf.h"
|
||||
#endif
|
||||
|
||||
#if (BOOT_COM_NET_PORT < 0)
|
||||
#error "BOOT_COM_NET_PORT must be >= 0"
|
||||
#endif
|
||||
#if (BOOT_COM_NET_PORT < 0)
|
||||
#error "BOOT_COM_NET_PORT must be >= 0"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_IPADDR_HOOK_ENABLE
|
||||
#define BOOT_COM_NET_IPADDR_HOOK_ENABLE (0)
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_IPADDR_HOOK_ENABLE
|
||||
#define BOOT_COM_NET_IPADDR_HOOK_ENABLE (0)
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_NETMASK_HOOK_ENABLE
|
||||
#define BOOT_COM_NET_NETMASK_HOOK_ENABLE (0)
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_NETMASK_HOOK_ENABLE
|
||||
#define BOOT_COM_NET_NETMASK_HOOK_ENABLE (0)
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_COM_NET_GATEWAY_HOOK_ENABLE
|
||||
#define BOOT_COM_NET_GATEWAY_HOOK_ENABLE (0)
|
||||
#endif
|
||||
#ifndef BOOT_COM_NET_GATEWAY_HOOK_ENABLE
|
||||
#define BOOT_COM_NET_GATEWAY_HOOK_ENABLE (0)
|
||||
#endif
|
||||
|
||||
#endif /* BOOT_COM_USB_ENABLE > 0 */
|
||||
|
||||
|
@ -386,37 +386,37 @@
|
|||
#endif
|
||||
|
||||
#if (BOOT_FILE_SYS_ENABLE > 0)
|
||||
#ifndef BOOT_FILE_LOGGING_ENABLE
|
||||
#define BOOT_FILE_LOGGING_ENABLE (0)
|
||||
#endif
|
||||
#ifndef BOOT_FILE_LOGGING_ENABLE
|
||||
#define BOOT_FILE_LOGGING_ENABLE (0)
|
||||
#endif
|
||||
|
||||
#if (BOOT_FILE_LOGGING_ENABLE < 0) || (BOOT_FILE_LOGGING_ENABLE > 1)
|
||||
#error "BOOT_FILE_LOGGING_ENABLE must be 0 or 1"
|
||||
#endif
|
||||
#if (BOOT_FILE_LOGGING_ENABLE < 0) || (BOOT_FILE_LOGGING_ENABLE > 1)
|
||||
#error "BOOT_FILE_LOGGING_ENABLE must be 0 or 1"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_FILE_ERROR_HOOK_ENABLE
|
||||
#define BOOT_FILE_ERROR_HOOK_ENABLE (0)
|
||||
#endif
|
||||
#ifndef BOOT_FILE_ERROR_HOOK_ENABLE
|
||||
#define BOOT_FILE_ERROR_HOOK_ENABLE (0)
|
||||
#endif
|
||||
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE < 0) || (BOOT_FILE_ERROR_HOOK_ENABLE > 1)
|
||||
#error "BOOT_FILE_ERROR_HOOK_ENABLE must be 0 or 1"
|
||||
#endif
|
||||
#if (BOOT_FILE_ERROR_HOOK_ENABLE < 0) || (BOOT_FILE_ERROR_HOOK_ENABLE > 1)
|
||||
#error "BOOT_FILE_ERROR_HOOK_ENABLE must be 0 or 1"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_FILE_STARTED_HOOK_ENABLE
|
||||
#define BOOT_FILE_STARTED_HOOK_ENABLE (0)
|
||||
#endif
|
||||
#ifndef BOOT_FILE_STARTED_HOOK_ENABLE
|
||||
#define BOOT_FILE_STARTED_HOOK_ENABLE (0)
|
||||
#endif
|
||||
|
||||
#if (BOOT_FILE_STARTED_HOOK_ENABLE < 0) || (BOOT_FILE_STARTED_HOOK_ENABLE > 1)
|
||||
#error "BOOT_FILE_STARTED_HOOK_ENABLE must be 0 or 1"
|
||||
#endif
|
||||
#if (BOOT_FILE_STARTED_HOOK_ENABLE < 0) || (BOOT_FILE_STARTED_HOOK_ENABLE > 1)
|
||||
#error "BOOT_FILE_STARTED_HOOK_ENABLE must be 0 or 1"
|
||||
#endif
|
||||
|
||||
#ifndef BOOT_FILE_COMPLETED_HOOK_ENABLE
|
||||
#define BOOT_FILE_COMPLETED_HOOK_ENABLE (0)
|
||||
#endif
|
||||
#ifndef BOOT_FILE_COMPLETED_HOOK_ENABLE
|
||||
#define BOOT_FILE_COMPLETED_HOOK_ENABLE (0)
|
||||
#endif
|
||||
|
||||
#if (BOOT_FILE_COMPLETED_HOOK_ENABLE < 0) || (BOOT_FILE_COMPLETED_HOOK_ENABLE > 1)
|
||||
#error "BOOT_FILE_COMPLETED_HOOK_ENABLE must be 0 or 1"
|
||||
#endif
|
||||
#if (BOOT_FILE_COMPLETED_HOOK_ENABLE < 0) || (BOOT_FILE_COMPLETED_HOOK_ENABLE > 1)
|
||||
#error "BOOT_FILE_COMPLETED_HOOK_ENABLE must be 0 or 1"
|
||||
#endif
|
||||
#endif /* BOOT_FILE_SYS_ENABLE > 0 */
|
||||
|
||||
#if (BOOT_COM_CAN_ENABLE == 1) || (BOOT_COM_UART_ENABLE == 1) || (BOOT_COM_NET_ENABLE == 1) || (BOOT_COM_USB_ENABLE == 1)
|
||||
|
|
|
@ -2,26 +2,29 @@
|
|||
/ Open or create a file in append mode
|
||||
/------------------------------------------------------------*/
|
||||
|
||||
FRESULT open_append (
|
||||
FIL* fp, /* [OUT] File object to create */
|
||||
const char* path /* [IN] File name to be opened */
|
||||
FRESULT open_append(
|
||||
FIL *fp, /* [OUT] File object to create */
|
||||
const char *path /* [IN] File name to be opened */
|
||||
)
|
||||
{
|
||||
FRESULT fr;
|
||||
|
||||
/* Opens an existing file. If not exist, creates a new file. */
|
||||
fr = f_open(fp, path, FA_WRITE | FA_OPEN_ALWAYS);
|
||||
if (fr == FR_OK) {
|
||||
if (fr == FR_OK)
|
||||
{
|
||||
/* Seek to end of the file to append data */
|
||||
fr = f_lseek(fp, f_size(fp));
|
||||
if (fr != FR_OK)
|
||||
{
|
||||
f_close(fp);
|
||||
}
|
||||
}
|
||||
return fr;
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
int main(void)
|
||||
{
|
||||
FRESULT fr;
|
||||
FIL fil;
|
||||
|
@ -31,7 +34,10 @@ int main (void)
|
|||
|
||||
/* Open or create a log file and ready to append */
|
||||
fr = open_append(&fil, "logfile.txt");
|
||||
if (fr != FR_OK) return 1;
|
||||
if (fr != FR_OK)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Append a line */
|
||||
f_printf(&fil, "%02u/%02u/%u, %2u:%02u\n", Mday, Mon, Year, Hour, Min);
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
/------------------------------------------------------------*/
|
||||
|
||||
|
||||
FRESULT empty_directory (
|
||||
char* path /* Working buffer filled with start directory */
|
||||
FRESULT empty_directory(
|
||||
char *path /* Working buffer filled with start directory */
|
||||
)
|
||||
{
|
||||
UINT i, j;
|
||||
|
@ -17,23 +17,40 @@ FRESULT empty_directory (
|
|||
fno.lfname = 0; /* Set null pointer because LFN is not needed */
|
||||
#endif
|
||||
fr = f_opendir(&dir, path);
|
||||
if (fr == FR_OK) {
|
||||
if (fr == FR_OK)
|
||||
{
|
||||
for (i = 0; path[i]; i++) ;
|
||||
path[i++] = '/';
|
||||
for (;;) {
|
||||
for (;;)
|
||||
{
|
||||
fr = f_readdir(&dir, &fno);
|
||||
if (fr != FR_OK || !fno.fname[0]) break;
|
||||
if (fno.fname[0] == '.') continue;
|
||||
if (fr != FR_OK || !fno.fname[0])
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (fno.fname[0] == '.')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
j = 0;
|
||||
do
|
||||
{
|
||||
path[i+j] = fno.fname[j];
|
||||
}
|
||||
while (fno.fname[j++]);
|
||||
if (fno.fattrib & AM_DIR) {
|
||||
if (fno.fattrib & AM_DIR)
|
||||
{
|
||||
fr = empty_directory(path);
|
||||
if (fr != FR_OK) break;
|
||||
if (fr != FR_OK)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
fr = f_unlink(path);
|
||||
if (fr != FR_OK) break;
|
||||
if (fr != FR_OK)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
path[--i] = '\0';
|
||||
}
|
||||
|
@ -43,7 +60,7 @@ FRESULT empty_directory (
|
|||
|
||||
|
||||
|
||||
int main (void)
|
||||
int main(void)
|
||||
{
|
||||
FRESULT fr;
|
||||
char buff[64]; /* Working buffer */
|
||||
|
@ -54,10 +71,13 @@ int main (void)
|
|||
strcpy(buff, "/"); /* Directory to be emptied */
|
||||
fr = empty_directory(buff);
|
||||
|
||||
if (fr) {
|
||||
if (fr)
|
||||
{
|
||||
printf("Function failed. (%u)\n", fr);
|
||||
return 1;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("All contents in the %s are successfully removed.\n", buff);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
|
||||
/* Declarations of FatFs internal functions accessible from applications.
|
||||
/ This is intended to be used by disk checking/fixing or dirty hacks :-) */
|
||||
DWORD clust2sect (FATFS *fs, DWORD clst);
|
||||
DWORD get_fat (FATFS *fs, DWORD clst);
|
||||
FRESULT put_fat (FATFS *fs, DWORD clst, DWORD val);
|
||||
DWORD clust2sect(FATFS *fs, DWORD clst);
|
||||
DWORD get_fat(FATFS *fs, DWORD clst);
|
||||
FRESULT put_fat(FATFS *fs, DWORD clst, DWORD val);
|
||||
|
||||
|
||||
DWORD allocate_contiguous_clusters ( /* Returns file start sector number */
|
||||
FIL* fp, /* Pointer to the open file object */
|
||||
DWORD allocate_contiguous_clusters( /* Returns file start sector number */
|
||||
FIL *fp, /* Pointer to the open file object */
|
||||
DWORD len /* Number of bytes to allocate */
|
||||
)
|
||||
{
|
||||
|
@ -20,49 +20,83 @@ DWORD allocate_contiguous_clusters ( /* Returns file start sector number */
|
|||
#endif
|
||||
|
||||
if (f_lseek(fp, 0) || !len) /* Check if the given parameters are valid */
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
csz = 512UL * fp->fs->csize; /* Cluster size in unit of byte (assuming 512 bytes/sector) */
|
||||
tcl = (len + csz - 1) / csz; /* Total number of clusters required */
|
||||
len = tcl * csz; /* Round-up file size to the cluster boundary */
|
||||
|
||||
/* Check if the existing cluster chain is contiguous */
|
||||
if (len == fp->fsize) {
|
||||
ncl = 0; ccl = fp->sclust;
|
||||
do {
|
||||
if (len == fp->fsize)
|
||||
{
|
||||
ncl = 0;
|
||||
ccl = fp->sclust;
|
||||
do
|
||||
{
|
||||
cl = get_fat(fp->fs, ccl); /* Get the cluster status */
|
||||
if (cl + 1 < 3) return 0; /* Hard error? */
|
||||
if (cl != ccl + 1 &&; cl < fp->fs->n_fatent) break; /* Not contiguous? */
|
||||
if (cl + 1 < 3)
|
||||
{
|
||||
return 0; /* Hard error? */
|
||||
}
|
||||
if (cl != ccl + 1 &&; cl < fp->fs->n_fatent)
|
||||
{
|
||||
break; /* Not contiguous? */
|
||||
}
|
||||
ccl = cl;
|
||||
} while (++ncl < tcl);
|
||||
}
|
||||
while (++ncl < tcl);
|
||||
if (ncl == tcl) /* Is the file contiguous? */
|
||||
{
|
||||
return clust2sect(fp->fs, fp->sclust); /* Return file start sector */
|
||||
}
|
||||
}
|
||||
|
||||
if (f_truncate(fp)) return 0; /* Remove the existing chain */
|
||||
if (f_truncate(fp))
|
||||
{
|
||||
return 0; /* Remove the existing chain */
|
||||
}
|
||||
|
||||
/* Find a free contiguous area */
|
||||
ccl = cl = 2; ncl = 0;
|
||||
do {
|
||||
if (cl >= fp->fs->n_fatent) return 0; /* No contiguous area is found. */
|
||||
if (get_fat(fp->fs, cl)) { /* Encounterd a cluster in use */
|
||||
do { /* Skip the block of used clusters */
|
||||
cl++;
|
||||
if (cl >= fp->fs->n_fatent) return 0; /* No contiguous area is found. */
|
||||
} while (get_fat(fp->fs, cl));
|
||||
ccl = cl; ncl = 0;
|
||||
ccl = cl = 2;
|
||||
ncl = 0;
|
||||
do
|
||||
{
|
||||
if (cl >= fp->fs->n_fatent)
|
||||
{
|
||||
return 0; /* No contiguous area is found. */
|
||||
}
|
||||
cl++; ncl++;
|
||||
} while (ncl < tcl);
|
||||
if (get_fat(fp->fs, cl)) /* Encounterd a cluster in use */
|
||||
{
|
||||
do /* Skip the block of used clusters */
|
||||
{
|
||||
cl++;
|
||||
if (cl >= fp->fs->n_fatent)
|
||||
{
|
||||
return 0; /* No contiguous area is found. */
|
||||
}
|
||||
}
|
||||
while (get_fat(fp->fs, cl));
|
||||
ccl = cl;
|
||||
ncl = 0;
|
||||
}
|
||||
cl++;
|
||||
ncl++;
|
||||
}
|
||||
while (ncl < tcl);
|
||||
|
||||
/* Create a contiguous cluster chain */
|
||||
fp->fs->last_clust = ccl - 1;
|
||||
if (f_lseek(fp, len)) return 0;
|
||||
if (f_lseek(fp, len))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return clust2sect(fp->fs, fp->sclust); /* Return file start sector */
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
int main(void)
|
||||
{
|
||||
FRESULT fr;
|
||||
DRESULT dr;
|
||||
|
@ -74,12 +108,16 @@ int main (void)
|
|||
|
||||
/* Open or create a file */
|
||||
fr = f_open(&fil, "pagefile.dat", FA_READ | FA_WRITE | FA_OPEN_ALWAYS);
|
||||
if (fr) return 1;
|
||||
if (fr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Check if the file is 64MB in size and occupies a contiguous area.
|
||||
/ If not, a contiguous area is re-allocated to the file. */
|
||||
org = allocate_contiguous_clusters(&fil, 0x4000000);
|
||||
if (!org) {
|
||||
if (!org)
|
||||
{
|
||||
printf("Function failed due to any error or insufficient contiguous area.\n");
|
||||
f_close(&fil);
|
||||
return 1;
|
||||
|
|
|
@ -19,7 +19,8 @@ extern "C" {
|
|||
typedef BYTE DSTATUS;
|
||||
|
||||
/* Results of Disk Functions */
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
RES_OK = 0, /* 0: Successful */
|
||||
RES_ERROR, /* 1: R/W Error */
|
||||
RES_WRPRT, /* 2: Write Protected */
|
||||
|
@ -32,11 +33,11 @@ typedef enum {
|
|||
/* Prototypes for disk control functions */
|
||||
|
||||
|
||||
DSTATUS disk_initialize (BYTE pdrv);
|
||||
DSTATUS disk_status (BYTE pdrv);
|
||||
DRESULT disk_read (BYTE pdrv, BYTE*buff, DWORD sector, BYTE count);
|
||||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count);
|
||||
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
DSTATUS disk_initialize(BYTE pdrv);
|
||||
DSTATUS disk_status(BYTE pdrv);
|
||||
DRESULT disk_read(BYTE pdrv, BYTE *buff, DWORD sector, BYTE count);
|
||||
DRESULT disk_write(BYTE pdrv, const BYTE *buff, DWORD sector, BYTE count);
|
||||
DRESULT disk_ioctl(BYTE pdrv, BYTE cmd, void *buff);
|
||||
|
||||
|
||||
/* Disk Status Bits (DSTATUS) */
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -33,7 +33,8 @@ extern "C" {
|
|||
/* Definitions of volume management */
|
||||
|
||||
#if _MULTI_PARTITION /* Multiple partition configuration */
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
BYTE pd; /* Physical drive number */
|
||||
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
|
||||
} PARTITION;
|
||||
|
@ -74,7 +75,8 @@ typedef char TCHAR;
|
|||
|
||||
/* File system object structure (FATFS) */
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
BYTE fs_type; /* FAT sub-type (0:Not mounted) */
|
||||
BYTE drv; /* Physical drive number */
|
||||
BYTE csize; /* Sectors per cluster (1,2,4...128) */
|
||||
|
@ -111,8 +113,9 @@ typedef struct {
|
|||
|
||||
/* File object structure (FIL) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the related file system object (**do not change order**) */
|
||||
typedef struct
|
||||
{
|
||||
FATFS *fs; /* Pointer to the related file system object (**do not change order**) */
|
||||
WORD id; /* Owner file system mount ID (**do not change order**) */
|
||||
BYTE flag; /* File status flags */
|
||||
BYTE pad1;
|
||||
|
@ -123,10 +126,10 @@ typedef struct {
|
|||
DWORD dsect; /* Current data sector of fpter */
|
||||
#if !_FS_READONLY
|
||||
DWORD dir_sect; /* Sector containing the directory entry */
|
||||
BYTE* dir_ptr; /* Pointer to the directory entry in the window */
|
||||
BYTE *dir_ptr; /* Pointer to the directory entry in the window */
|
||||
#endif
|
||||
#if _USE_FASTSEEK
|
||||
DWORD* cltbl; /* Pointer to the cluster link map table (null on file open) */
|
||||
DWORD *cltbl; /* Pointer to the cluster link map table (null on file open) */
|
||||
#endif
|
||||
#if _FS_LOCK
|
||||
UINT lockid; /* File lock ID (index of file semaphore table Files[]) */
|
||||
|
@ -140,17 +143,18 @@ typedef struct {
|
|||
|
||||
/* Directory object structure (DIR) */
|
||||
|
||||
typedef struct {
|
||||
FATFS* fs; /* Pointer to the owner file system object (**do not change order**) */
|
||||
typedef struct
|
||||
{
|
||||
FATFS *fs; /* Pointer to the owner file system object (**do not change order**) */
|
||||
WORD id; /* Owner file system mount ID (**do not change order**) */
|
||||
WORD index; /* Current read/write index number */
|
||||
DWORD sclust; /* Table start cluster (0:Root dir) */
|
||||
DWORD clust; /* Current cluster */
|
||||
DWORD sect; /* Current sector */
|
||||
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
|
||||
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
||||
BYTE *dir; /* Pointer to the current SFN entry in the win[] */
|
||||
BYTE *fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
||||
#if _USE_LFN
|
||||
WCHAR* lfn; /* Pointer to the LFN working buffer */
|
||||
WCHAR *lfn; /* Pointer to the LFN working buffer */
|
||||
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
|
||||
#endif
|
||||
} DIR;
|
||||
|
@ -159,14 +163,15 @@ typedef struct {
|
|||
|
||||
/* File status structure (FILINFO) */
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
DWORD fsize; /* File size */
|
||||
WORD fdate; /* Last modified date */
|
||||
WORD ftime; /* Last modified time */
|
||||
BYTE fattrib; /* Attribute */
|
||||
TCHAR fname[13]; /* Short file name (8.3 format) */
|
||||
#if _USE_LFN
|
||||
TCHAR* lfname; /* Pointer to the LFN buffer */
|
||||
TCHAR *lfname; /* Pointer to the LFN buffer */
|
||||
UINT lfsize; /* Size of LFN buffer in TCHAR */
|
||||
#endif
|
||||
} FILINFO;
|
||||
|
@ -175,7 +180,8 @@ typedef struct {
|
|||
|
||||
/* File function return code (FRESULT) */
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
FR_OK = 0, /* (0) Succeeded */
|
||||
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
|
||||
FR_INT_ERR, /* (2) Assertion failed */
|
||||
|
@ -203,35 +209,35 @@ typedef enum {
|
|||
/*--------------------------------------------------------------*/
|
||||
/* FatFs module application interface */
|
||||
|
||||
FRESULT f_mount (BYTE vol, FATFS* fs); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode); /* Open or create a file */
|
||||
FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br); /* Read data from a file */
|
||||
FRESULT f_lseek (FIL* fp, DWORD ofs); /* Move file pointer of a file object */
|
||||
FRESULT f_close (FIL* fp); /* Close an open file object */
|
||||
FRESULT f_opendir (DIR* dj, const TCHAR* path); /* Open an existing directory */
|
||||
FRESULT f_readdir (DIR* dj, FILINFO* fno); /* Read a directory item */
|
||||
FRESULT f_stat (const TCHAR* path, FILINFO* fno); /* Get file status */
|
||||
FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw); /* Write data to a file */
|
||||
FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */
|
||||
FRESULT f_truncate (FIL* fp); /* Truncate file */
|
||||
FRESULT f_sync (FIL* fp); /* Flush cached data of a writing file */
|
||||
FRESULT f_unlink (const TCHAR* path); /* Delete an existing file or directory */
|
||||
FRESULT f_mkdir (const TCHAR* path); /* Create a new directory */
|
||||
FRESULT f_chmod (const TCHAR* path, BYTE value, BYTE mask); /* Change attribute of the file/dir */
|
||||
FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp of the file/dir */
|
||||
FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new); /* Rename/Move a file or directory */
|
||||
FRESULT f_chdrive (BYTE drv); /* Change current drive */
|
||||
FRESULT f_chdir (const TCHAR* path); /* Change current directory */
|
||||
FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */
|
||||
FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* sn); /* Get volume label */
|
||||
FRESULT f_setlabel (const TCHAR* label); /* Set volume label */
|
||||
FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf); /* Forward data to the stream */
|
||||
FRESULT f_mkfs (BYTE vol, BYTE sfd, UINT au); /* Create a file system on the drive */
|
||||
FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */
|
||||
int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */
|
||||
int f_puts (const TCHAR* str, FIL* cp); /* Put a string to the file */
|
||||
int f_printf (FIL* fp, const TCHAR* str, ...); /* Put a formatted string to the file */
|
||||
TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the file */
|
||||
FRESULT f_mount(BYTE vol, FATFS *fs); /* Mount/Unmount a logical drive */
|
||||
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode); /* Open or create a file */
|
||||
FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br); /* Read data from a file */
|
||||
FRESULT f_lseek(FIL *fp, DWORD ofs); /* Move file pointer of a file object */
|
||||
FRESULT f_close(FIL *fp); /* Close an open file object */
|
||||
FRESULT f_opendir(DIR *dj, const TCHAR *path); /* Open an existing directory */
|
||||
FRESULT f_readdir(DIR *dj, FILINFO *fno); /* Read a directory item */
|
||||
FRESULT f_stat(const TCHAR *path, FILINFO *fno); /* Get file status */
|
||||
FRESULT f_write(FIL *fp, const void *buff, UINT btw, UINT *bw); /* Write data to a file */
|
||||
FRESULT f_getfree(const TCHAR *path, DWORD *nclst, FATFS **fatfs); /* Get number of free clusters on the drive */
|
||||
FRESULT f_truncate(FIL *fp); /* Truncate file */
|
||||
FRESULT f_sync(FIL *fp); /* Flush cached data of a writing file */
|
||||
FRESULT f_unlink(const TCHAR *path); /* Delete an existing file or directory */
|
||||
FRESULT f_mkdir(const TCHAR *path); /* Create a new directory */
|
||||
FRESULT f_chmod(const TCHAR *path, BYTE value, BYTE mask); /* Change attribute of the file/dir */
|
||||
FRESULT f_utime(const TCHAR *path, const FILINFO *fno); /* Change times-tamp of the file/dir */
|
||||
FRESULT f_rename(const TCHAR *path_old, const TCHAR *path_new); /* Rename/Move a file or directory */
|
||||
FRESULT f_chdrive(BYTE drv); /* Change current drive */
|
||||
FRESULT f_chdir(const TCHAR *path); /* Change current directory */
|
||||
FRESULT f_getcwd(TCHAR *buff, UINT len); /* Get current directory */
|
||||
FRESULT f_getlabel(const TCHAR *path, TCHAR *label, DWORD *sn); /* Get volume label */
|
||||
FRESULT f_setlabel(const TCHAR *label); /* Set volume label */
|
||||
FRESULT f_forward(FIL *fp, UINT(*func)(const BYTE *,UINT), UINT btf, UINT *bf); /* Forward data to the stream */
|
||||
FRESULT f_mkfs(BYTE vol, BYTE sfd, UINT au); /* Create a file system on the drive */
|
||||
FRESULT f_fdisk(BYTE pdrv, const DWORD szt[], void *work); /* Divide a physical drive into some partitions */
|
||||
int f_putc(TCHAR c, FIL *fp); /* Put a character to the file */
|
||||
int f_puts(const TCHAR *str, FIL *cp); /* Put a string to the file */
|
||||
int f_printf(FIL *fp, const TCHAR *str, ...); /* Put a formatted string to the file */
|
||||
TCHAR *f_gets(TCHAR *buff, int len, FIL *fp); /* Get a string from the file */
|
||||
|
||||
#define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
|
||||
#define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
|
||||
|
@ -250,25 +256,25 @@ TCHAR* f_gets (TCHAR* buff, int len, FIL* fp); /* Get a string from the fil
|
|||
|
||||
/* RTC function */
|
||||
#if !_FS_READONLY
|
||||
DWORD get_fattime (void);
|
||||
DWORD get_fattime(void);
|
||||
#endif
|
||||
|
||||
/* Unicode support functions */
|
||||
#if _USE_LFN /* Unicode - OEM code conversion */
|
||||
WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */
|
||||
WCHAR ff_wtoupper (WCHAR chr); /* Unicode upper-case conversion */
|
||||
WCHAR ff_convert(WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */
|
||||
WCHAR ff_wtoupper(WCHAR chr); /* Unicode upper-case conversion */
|
||||
#if _USE_LFN == 3 /* Memory functions */
|
||||
void* ff_memalloc (UINT msize); /* Allocate memory block */
|
||||
void ff_memfree (void* mblock); /* Free memory block */
|
||||
void *ff_memalloc(UINT msize); /* Allocate memory block */
|
||||
void ff_memfree(void *mblock); /* Free memory block */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Sync functions */
|
||||
#if _FS_REENTRANT
|
||||
int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj); /* Create a sync object */
|
||||
int ff_req_grant (_SYNC_t sobj); /* Lock sync object */
|
||||
void ff_rel_grant (_SYNC_t sobj); /* Unlock sync object */
|
||||
int ff_del_syncobj (_SYNC_t sobj); /* Delete a sync object */
|
||||
int ff_cre_syncobj(BYTE vol, _SYNC_t *sobj); /* Create a sync object */
|
||||
int ff_req_grant(_SYNC_t sobj); /* Lock sync object */
|
||||
void ff_rel_grant(_SYNC_t sobj); /* Unlock sync object */
|
||||
int ff_del_syncobj(_SYNC_t sobj); /* Delete a sync object */
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
|
||||
|
||||
static
|
||||
const WCHAR uni2sjis[] = {
|
||||
/* Unicode - Sjis, Unicode - Sjis, Unicode - Sjis, Unicode - Sjis, */
|
||||
const WCHAR uni2sjis[] =
|
||||
{
|
||||
/* Unicode - Sjis, Unicode - Sjis, Unicode - Sjis, Unicode - Sjis, */
|
||||
0x00A7, 0x8198, 0x00A8, 0x814E, 0x00B0, 0x818B, 0x00B1, 0x817D,
|
||||
0x00B4, 0x814C, 0x00B6, 0x81F7, 0x00D7, 0x817E, 0x00F7, 0x8180,
|
||||
0x0391, 0x839F, 0x0392, 0x83A0, 0x0393, 0x83A1, 0x0394, 0x83A2,
|
||||
|
@ -1868,8 +1869,9 @@ const WCHAR uni2sjis[] = {
|
|||
|
||||
#if !_TINY_TABLE
|
||||
static
|
||||
const WCHAR sjis2uni[] = {
|
||||
/* SJIS - Unicode, SJIS - Unicode, SJIS - Unicode, SJIS - Unicode, */
|
||||
const WCHAR sjis2uni[] =
|
||||
{
|
||||
/* SJIS - Unicode, SJIS - Unicode, SJIS - Unicode, SJIS - Unicode, */
|
||||
0x00A1, 0xFF61, 0x00A2, 0xFF62, 0x00A3, 0xFF63, 0x00A4, 0xFF64,
|
||||
0x00A5, 0xFF65, 0x00A6, 0xFF66, 0x00A7, 0xFF67, 0x00A8, 0xFF68,
|
||||
0x00A9, 0xFF69, 0x00AA, 0xFF6A, 0x00AB, 0xFF6B, 0x00AC, 0xFF6C,
|
||||
|
@ -3723,7 +3725,7 @@ const WCHAR sjis2uni[] = {
|
|||
|
||||
|
||||
|
||||
WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
||||
WCHAR ff_convert( /* Converted code, 0 means conversion error */
|
||||
WCHAR chr, /* Character code to be converted */
|
||||
UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */
|
||||
)
|
||||
|
@ -3733,46 +3735,74 @@ WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
|||
int i, n, li, hi;
|
||||
|
||||
|
||||
if (chr <= 0x80) { /* ASCII */
|
||||
if (chr <= 0x80) /* ASCII */
|
||||
{
|
||||
c = chr;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !_TINY_TABLE
|
||||
if (dir) { /* OEMCP to unicode */
|
||||
if (dir) /* OEMCP to unicode */
|
||||
{
|
||||
p = sjis2uni;
|
||||
hi = sizeof(sjis2uni) / 4 - 1;
|
||||
} else { /* Unicode to OEMCP */
|
||||
}
|
||||
else /* Unicode to OEMCP */
|
||||
{
|
||||
p = uni2sjis;
|
||||
hi = sizeof(uni2sjis) / 4 - 1;
|
||||
}
|
||||
li = 0;
|
||||
for (n = 16; n; n--) {
|
||||
for (n = 16; n; n--)
|
||||
{
|
||||
i = li + (hi - li) / 2;
|
||||
if (chr == p[i * 2]) break;
|
||||
if (chr == p[i * 2])
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (chr > p[i * 2])
|
||||
{
|
||||
li = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
hi = i;
|
||||
}
|
||||
}
|
||||
c = n ? p[i * 2 + 1] : 0;
|
||||
#else
|
||||
if (dir) { /* OEMCP to unicode (Incremental search)*/
|
||||
if (dir) /* OEMCP to unicode (Incremental search)*/
|
||||
{
|
||||
p = &uni2sjis[1];
|
||||
do {
|
||||
do
|
||||
{
|
||||
c = *p;
|
||||
p += 2;
|
||||
} while (c && c != chr);
|
||||
}
|
||||
while (c && c != chr);
|
||||
p -= 3;
|
||||
c = *p;
|
||||
} else { /* Unicode to OEMCP */
|
||||
li = 0; hi = sizeof(uni2sjis) / 4 - 1;
|
||||
for (n = 16; n; n--) {
|
||||
}
|
||||
else /* Unicode to OEMCP */
|
||||
{
|
||||
li = 0;
|
||||
hi = sizeof(uni2sjis) / 4 - 1;
|
||||
for (n = 16; n; n--)
|
||||
{
|
||||
i = li + (hi - li) / 2;
|
||||
if (chr == uni2sjis[i * 2]) break;
|
||||
if (chr == uni2sjis[i * 2])
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (chr > uni2sjis[i * 2])
|
||||
{
|
||||
li = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
hi = i;
|
||||
}
|
||||
}
|
||||
c = n ? uni2sjis[i * 2 + 1] : 0;
|
||||
}
|
||||
#endif
|
||||
|
@ -3783,7 +3813,7 @@ WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
|||
|
||||
|
||||
|
||||
WCHAR ff_wtoupper ( /* Upper converted character */
|
||||
WCHAR ff_wtoupper( /* Upper converted character */
|
||||
WCHAR chr /* Input character */
|
||||
)
|
||||
{
|
||||
|
|
|
@ -12,8 +12,9 @@
|
|||
#endif
|
||||
|
||||
static
|
||||
const WCHAR uni2oem[] = {
|
||||
/* Unicode - OEM, Unicode - OEM, Unicode - OEM, Unicode - OEM */
|
||||
const WCHAR uni2oem[] =
|
||||
{
|
||||
/* Unicode - OEM, Unicode - OEM, Unicode - OEM, Unicode - OEM */
|
||||
0x00A4, 0xA1E8, 0x00A7, 0xA1EC, 0x00A8, 0xA1A7, 0x00B0, 0xA1E3,
|
||||
0x00B1, 0xA1C0, 0x00B7, 0xA1A4, 0x00D7, 0xA1C1, 0x00E0, 0xA8A4,
|
||||
0x00E1, 0xA8A2, 0x00E8, 0xA8A8, 0x00E9, 0xA8A6, 0x00EA, 0xA8BA,
|
||||
|
@ -5466,8 +5467,9 @@ const WCHAR uni2oem[] = {
|
|||
};
|
||||
|
||||
static
|
||||
const WCHAR oem2uni[] = {
|
||||
/* OEM - Unicode, OEM - Unicode, OEM - Unicode, OEM - Unicode */
|
||||
const WCHAR oem2uni[] =
|
||||
{
|
||||
/* OEM - Unicode, OEM - Unicode, OEM - Unicode, OEM - Unicode */
|
||||
0x0080, 0x20AC, 0x8140, 0x4E02, 0x8141, 0x4E04, 0x8142, 0x4E05,
|
||||
0x8143, 0x4E06, 0x8144, 0x4E0F, 0x8145, 0x4E12, 0x8146, 0x4E17,
|
||||
0x8147, 0x4E1F, 0x8148, 0x4E20, 0x8149, 0x4E21, 0x814A, 0x4E23,
|
||||
|
@ -10921,7 +10923,7 @@ const WCHAR oem2uni[] = {
|
|||
|
||||
|
||||
|
||||
WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
||||
WCHAR ff_convert( /* Converted code, 0 means conversion error */
|
||||
WCHAR chr, /* Character code to be converted */
|
||||
UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */
|
||||
)
|
||||
|
@ -10931,25 +10933,39 @@ WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
|||
int i, n, li, hi;
|
||||
|
||||
|
||||
if (chr < 0x80) { /* ASCII */
|
||||
if (chr < 0x80) /* ASCII */
|
||||
{
|
||||
c = chr;
|
||||
} else {
|
||||
if (dir) { /* OEMCP to unicode */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dir) /* OEMCP to unicode */
|
||||
{
|
||||
p = oem2uni;
|
||||
hi = sizeof(oem2uni) / 4 - 1;
|
||||
} else { /* Unicode to OEMCP */
|
||||
}
|
||||
else /* Unicode to OEMCP */
|
||||
{
|
||||
p = uni2oem;
|
||||
hi = sizeof(uni2oem) / 4 - 1;
|
||||
}
|
||||
li = 0;
|
||||
for (n = 16; n; n--) {
|
||||
for (n = 16; n; n--)
|
||||
{
|
||||
i = li + (hi - li) / 2;
|
||||
if (chr == p[i * 2]) break;
|
||||
if (chr == p[i * 2])
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (chr > p[i * 2])
|
||||
{
|
||||
li = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
hi = i;
|
||||
}
|
||||
}
|
||||
c = n ? p[i * 2 + 1] : 0;
|
||||
}
|
||||
|
||||
|
@ -10958,7 +10974,7 @@ WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
|||
|
||||
|
||||
|
||||
WCHAR ff_wtoupper ( /* Upper converted character */
|
||||
WCHAR ff_wtoupper( /* Upper converted character */
|
||||
WCHAR chr /* Input character */
|
||||
)
|
||||
{
|
||||
|
|
|
@ -13,8 +13,9 @@
|
|||
|
||||
|
||||
static
|
||||
const WCHAR uni2oem[] = {
|
||||
/* Unicode - OEM, Unicode - OEM, Unicode - OEM, Unicode - OEM */
|
||||
const WCHAR uni2oem[] =
|
||||
{
|
||||
/* Unicode - OEM, Unicode - OEM, Unicode - OEM, Unicode - OEM */
|
||||
0x00A1, 0xA2AE, 0x00A4, 0xA2B4, 0x00A7, 0xA1D7, 0x00A8, 0xA1A7,
|
||||
0x00AA, 0xA8A3, 0x00AD, 0xA1A9, 0x00AE, 0xA2E7, 0x00B0, 0xA1C6,
|
||||
0x00B1, 0xA1BE, 0x00B2, 0xA9F7, 0x00B3, 0xA9F8, 0x00B4, 0xA2A5,
|
||||
|
@ -4281,8 +4282,9 @@ const WCHAR uni2oem[] = {
|
|||
};
|
||||
|
||||
static
|
||||
const WCHAR oem2uni[] = {
|
||||
/* OEM - Unicode, OEM - Unicode, OEM - Unicode, OEM - Unicode */
|
||||
const WCHAR oem2uni[] =
|
||||
{
|
||||
/* OEM - Unicode, OEM - Unicode, OEM - Unicode, OEM - Unicode */
|
||||
0x8141, 0xAC02, 0x8142, 0xAC03, 0x8143, 0xAC05, 0x8144, 0xAC06,
|
||||
0x8145, 0xAC0B, 0x8146, 0xAC0C, 0x8147, 0xAC0D, 0x8148, 0xAC0E,
|
||||
0x8149, 0xAC0F, 0x814A, 0xAC18, 0x814B, 0xAC1E, 0x814C, 0xAC1F,
|
||||
|
@ -8550,7 +8552,7 @@ const WCHAR oem2uni[] = {
|
|||
|
||||
|
||||
|
||||
WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
||||
WCHAR ff_convert( /* Converted code, 0 means conversion error */
|
||||
WCHAR chr, /* Character code to be converted */
|
||||
UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */
|
||||
)
|
||||
|
@ -8560,25 +8562,39 @@ WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
|||
int i, n, li, hi;
|
||||
|
||||
|
||||
if (chr < 0x80) { /* ASCII */
|
||||
if (chr < 0x80) /* ASCII */
|
||||
{
|
||||
c = chr;
|
||||
} else {
|
||||
if (dir) { /* OEMCP to unicode */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dir) /* OEMCP to unicode */
|
||||
{
|
||||
p = oem2uni;
|
||||
hi = sizeof(oem2uni) / 4 - 1;
|
||||
} else { /* Unicode to OEMCP */
|
||||
}
|
||||
else /* Unicode to OEMCP */
|
||||
{
|
||||
p = uni2oem;
|
||||
hi = sizeof(uni2oem) / 4 - 1;
|
||||
}
|
||||
li = 0;
|
||||
for (n = 16; n; n--) {
|
||||
for (n = 16; n; n--)
|
||||
{
|
||||
i = li + (hi - li) / 2;
|
||||
if (chr == p[i * 2]) break;
|
||||
if (chr == p[i * 2])
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (chr > p[i * 2])
|
||||
{
|
||||
li = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
hi = i;
|
||||
}
|
||||
}
|
||||
c = n ? p[i * 2 + 1] : 0;
|
||||
}
|
||||
|
||||
|
@ -8588,7 +8604,7 @@ WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
|||
|
||||
|
||||
|
||||
WCHAR ff_wtoupper ( /* Upper converted character */
|
||||
WCHAR ff_wtoupper( /* Upper converted character */
|
||||
WCHAR chr /* Input character */
|
||||
)
|
||||
{
|
||||
|
|
|
@ -13,8 +13,9 @@
|
|||
|
||||
|
||||
static
|
||||
const WCHAR uni2oem[] = {
|
||||
/* Unicode - OEM, Unicode - OEM, Unicode - OEM, Unicode - OEM */
|
||||
const WCHAR uni2oem[] =
|
||||
{
|
||||
/* Unicode - OEM, Unicode - OEM, Unicode - OEM, Unicode - OEM */
|
||||
0x00A7, 0xA1B1, 0x00AF, 0xA1C2, 0x00B0, 0xA258, 0x00B1, 0xA1D3,
|
||||
0x00B7, 0xA150, 0x00D7, 0xA1D1, 0x00F7, 0xA1D2, 0x02C7, 0xA3BE,
|
||||
0x02C9, 0xA3BC, 0x02CA, 0xA3BD, 0x02CB, 0xA3BF, 0x02CD, 0xA1C5,
|
||||
|
@ -3394,8 +3395,9 @@ const WCHAR uni2oem[] = {
|
|||
};
|
||||
|
||||
static
|
||||
const WCHAR oem2uni[] = {
|
||||
/* OEM - Unicode, OEM - Unicode, OEM - Unicode, OEM - Unicode */
|
||||
const WCHAR oem2uni[] =
|
||||
{
|
||||
/* OEM - Unicode, OEM - Unicode, OEM - Unicode, OEM - Unicode */
|
||||
0xA140, 0x3000, 0xA141, 0xFF0C, 0xA142, 0x3001, 0xA143, 0x3002,
|
||||
0xA144, 0xFF0E, 0xA145, 0x2027, 0xA146, 0xFF1B, 0xA147, 0xFF1A,
|
||||
0xA148, 0xFF1F, 0xA149, 0xFF01, 0xA14A, 0xFE30, 0xA14B, 0x2026,
|
||||
|
@ -6776,7 +6778,7 @@ const WCHAR oem2uni[] = {
|
|||
|
||||
|
||||
|
||||
WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
||||
WCHAR ff_convert( /* Converted code, 0 means conversion error */
|
||||
WCHAR chr, /* Character code to be converted */
|
||||
UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */
|
||||
)
|
||||
|
@ -6786,25 +6788,39 @@ WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
|||
int i, n, li, hi;
|
||||
|
||||
|
||||
if (chr < 0x80) { /* ASCII */
|
||||
if (chr < 0x80) /* ASCII */
|
||||
{
|
||||
c = chr;
|
||||
} else {
|
||||
if (dir) { /* OEMCP to unicode */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dir) /* OEMCP to unicode */
|
||||
{
|
||||
p = oem2uni;
|
||||
hi = sizeof(oem2uni) / 4 - 1;
|
||||
} else { /* Unicode to OEMCP */
|
||||
}
|
||||
else /* Unicode to OEMCP */
|
||||
{
|
||||
p = uni2oem;
|
||||
hi = sizeof(uni2oem) / 4 - 1;
|
||||
}
|
||||
li = 0;
|
||||
for (n = 16; n; n--) {
|
||||
for (n = 16; n; n--)
|
||||
{
|
||||
i = li + (hi - li) / 2;
|
||||
if (chr == p[i * 2]) break;
|
||||
if (chr == p[i * 2])
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (chr > p[i * 2])
|
||||
{
|
||||
li = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
hi = i;
|
||||
}
|
||||
}
|
||||
c = n ? p[i * 2 + 1] : 0;
|
||||
}
|
||||
|
||||
|
@ -6814,7 +6830,7 @@ WCHAR ff_convert ( /* Converted code, 0 means conversion error */
|
|||
|
||||
|
||||
|
||||
WCHAR ff_wtoupper ( /* Upper converted character */
|
||||
WCHAR ff_wtoupper( /* Upper converted character */
|
||||
WCHAR chr /* Input character */
|
||||
)
|
||||
{
|
||||
|
|
|
@ -31,7 +31,8 @@
|
|||
#if _CODE_PAGE == 437
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP437(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
||||
|
@ -53,7 +54,8 @@ const WCHAR Tbl[] = { /* CP437(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 720
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP720(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x0000, 0x0000, 0x00E9, 0x00E2, 0x0000, 0x00E0, 0x0000, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0651, 0x0652, 0x00F4, 0x00A4, 0x0640, 0x00FB, 0x00F9,
|
||||
|
@ -75,7 +77,8 @@ const WCHAR Tbl[] = { /* CP720(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 737
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP737(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398,
|
||||
0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F, 0x03A0,
|
||||
0x03A1, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03A9,
|
||||
|
@ -97,7 +100,8 @@ const WCHAR Tbl[] = { /* CP737(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 775
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP775(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x0106, 0x00FC, 0x00E9, 0x0101, 0x00E4, 0x0123, 0x00E5, 0x0107,
|
||||
0x0142, 0x0113, 0x0156, 0x0157, 0x012B, 0x0179, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x014D, 0x00F6, 0x0122, 0x00A2, 0x015A,
|
||||
|
@ -119,7 +123,8 @@ const WCHAR Tbl[] = { /* CP775(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 850
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP850(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
||||
|
@ -141,7 +146,8 @@ const WCHAR Tbl[] = { /* CP850(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 852
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP852(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x016F, 0x0107, 0x00E7,
|
||||
0x0142, 0x00EB, 0x0150, 0x0151, 0x00EE, 0x0179, 0x00C4, 0x0106,
|
||||
0x00C9, 0x0139, 0x013A, 0x00F4, 0x00F6, 0x013D, 0x013E, 0x015A,
|
||||
|
@ -163,7 +169,8 @@ const WCHAR Tbl[] = { /* CP852(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 855
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP855(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x0452, 0x0402, 0x0453, 0x0403, 0x0451, 0x0401, 0x0454, 0x0404,
|
||||
0x0455, 0x0405, 0x0456, 0x0406, 0x0457, 0x0407, 0x0458, 0x0408,
|
||||
0x0459, 0x0409, 0x045A, 0x040A, 0x045B, 0x040B, 0x045C, 0x040C,
|
||||
|
@ -185,7 +192,8 @@ const WCHAR Tbl[] = { /* CP855(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 857
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP857(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x0131, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
||||
|
@ -207,7 +215,8 @@ const WCHAR Tbl[] = { /* CP857(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 858
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP858(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP858(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
||||
|
@ -229,7 +238,8 @@ const WCHAR Tbl[] = { /* CP858(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 862
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP862(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
|
||||
0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
|
||||
0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
|
||||
|
@ -251,7 +261,8 @@ const WCHAR Tbl[] = { /* CP862(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 866
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP866(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
|
||||
0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
|
||||
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
|
||||
|
@ -273,7 +284,8 @@ const WCHAR Tbl[] = { /* CP866(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 874
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP874(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP874(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x20AC, 0x0000, 0x0000, 0x0000, 0x0000, 0x2026, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
|
@ -295,7 +307,8 @@ const WCHAR Tbl[] = { /* CP874(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 1250
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1250(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP1250(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x0000, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
|
@ -317,7 +330,8 @@ const WCHAR Tbl[] = { /* CP1250(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 1251
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1251(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP1251(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
|
||||
0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
|
@ -339,7 +353,8 @@ const WCHAR Tbl[] = { /* CP1251(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 1252
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1252(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP1252(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x017D, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
|
@ -361,7 +376,8 @@ const WCHAR Tbl[] = { /* CP1252(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 1253
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1253(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP1253(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x0000, 0x2030, 0x0000, 0x2039, 0x000C, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
|
@ -383,7 +399,8 @@ const WCHAR Tbl[] = { /* CP1253(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 1254
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1254(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP1254(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x20AC, 0x0000, 0x210A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
|
@ -405,7 +422,8 @@ const WCHAR Tbl[] = { /* CP1254(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 1255
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1255(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP1255(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x02C6, 0x2030, 0x0000, 0x2039, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
|
@ -427,7 +445,8 @@ const WCHAR Tbl[] = { /* CP1255(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 1256
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1256(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP1256(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x02C6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688,
|
||||
0x06AF, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
|
@ -449,7 +468,8 @@ const WCHAR Tbl[] = { /* CP1256(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 1257
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1257(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP1257(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x20AC, 0x0000, 0x201A, 0x0000, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x0000, 0x2030, 0x0000, 0x2039, 0x0000, 0x00A8, 0x02C7, 0x00B8,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
|
@ -471,7 +491,8 @@ const WCHAR Tbl[] = { /* CP1257(0x80-0xFF) to Unicode conversion table */
|
|||
#elif _CODE_PAGE == 1258
|
||||
#define _TBLDEF 1
|
||||
static
|
||||
const WCHAR Tbl[] = { /* CP1258(0x80-0xFF) to Unicode conversion table */
|
||||
const WCHAR Tbl[] = /* CP1258(0x80-0xFF) to Unicode conversion table */
|
||||
{
|
||||
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x02C6, 0x2030, 0x0000, 0x2039, 0x0152, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
|
@ -498,7 +519,7 @@ const WCHAR Tbl[] = { /* CP1258(0x80-0xFF) to Unicode conversion table */
|
|||
#endif
|
||||
|
||||
|
||||
WCHAR ff_convert ( /* Converted character, Returns zero on error */
|
||||
WCHAR ff_convert( /* Converted character, Returns zero on error */
|
||||
WCHAR chr, /* Character code to be converted */
|
||||
UINT dir /* 0: Unicode to OEMCP, 1: OEMCP to Unicode */
|
||||
)
|
||||
|
@ -506,16 +527,26 @@ WCHAR ff_convert ( /* Converted character, Returns zero on error */
|
|||
WCHAR c;
|
||||
|
||||
|
||||
if (chr < 0x80) { /* ASCII */
|
||||
if (chr < 0x80) /* ASCII */
|
||||
{
|
||||
c = chr;
|
||||
|
||||
} else {
|
||||
if (dir) { /* OEMCP to Unicode */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dir) /* OEMCP to Unicode */
|
||||
{
|
||||
c = (chr >= 0x100) ? 0 : Tbl[chr - 0x80];
|
||||
|
||||
} else { /* Unicode to OEMCP */
|
||||
for (c = 0; c < 0x80; c++) {
|
||||
if (chr == Tbl[c]) break;
|
||||
}
|
||||
else /* Unicode to OEMCP */
|
||||
{
|
||||
for (c = 0; c < 0x80; c++)
|
||||
{
|
||||
if (chr == Tbl[c])
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
c = (c + 0x80) & 0xFF;
|
||||
}
|
||||
|
@ -525,7 +556,7 @@ WCHAR ff_convert ( /* Converted character, Returns zero on error */
|
|||
}
|
||||
|
||||
|
||||
WCHAR ff_wtoupper ( /* Upper converted character */
|
||||
WCHAR ff_wtoupper( /* Upper converted character */
|
||||
WCHAR chr /* Input character */
|
||||
)
|
||||
{
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
/ returned, the f_mount function fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create due to any error */
|
||||
int ff_cre_syncobj( /* 1:Function succeeded, 0:Could not create due to any error */
|
||||
BYTE vol, /* Corresponding logical drive being processed */
|
||||
_SYNC_t *sobj /* Pointer to return the created sync object */
|
||||
)
|
||||
|
@ -54,7 +54,7 @@ int ff_cre_syncobj ( /* 1:Function succeeded, 0:Could not create due to any erro
|
|||
/ returned, the f_mount function fails with FR_INT_ERR.
|
||||
*/
|
||||
|
||||
int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to any error */
|
||||
int ff_del_syncobj( /* 1:Function succeeded, 0:Could not delete due to any error */
|
||||
_SYNC_t sobj /* Sync object tied to the logical drive to be deleted */
|
||||
)
|
||||
{
|
||||
|
@ -82,7 +82,7 @@ int ff_del_syncobj ( /* 1:Function succeeded, 0:Could not delete due to any erro
|
|||
/ When a FALSE is returned, the file function fails with FR_TIMEOUT.
|
||||
*/
|
||||
|
||||
int ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */
|
||||
int ff_req_grant( /* TRUE:Got a grant to access the volume, FALSE:Could not get a grant */
|
||||
_SYNC_t sobj /* Sync object to wait */
|
||||
)
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ int ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not get
|
|||
/* This function is called on leaving file functions to unlock the volume.
|
||||
*/
|
||||
|
||||
void ff_rel_grant (
|
||||
void ff_rel_grant(
|
||||
_SYNC_t sobj /* Sync object to be signaled */
|
||||
)
|
||||
{
|
||||
|
@ -133,7 +133,7 @@ void ff_rel_grant (
|
|||
/* If a NULL is returned, the file function fails with FR_NOT_ENOUGH_CORE.
|
||||
*/
|
||||
|
||||
void* ff_memalloc ( /* Returns pointer to the allocated memory block */
|
||||
void *ff_memalloc( /* Returns pointer to the allocated memory block */
|
||||
UINT msize /* Number of bytes to allocate */
|
||||
)
|
||||
{
|
||||
|
@ -145,8 +145,8 @@ void* ff_memalloc ( /* Returns pointer to the allocated memory block */
|
|||
/* Free a memory block */
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
void ff_memfree (
|
||||
void* mblock /* Pointer to the memory block to free */
|
||||
void ff_memfree(
|
||||
void *mblock /* Pointer to the memory block to free */
|
||||
)
|
||||
{
|
||||
free(mblock);
|
||||
|
|
|
@ -46,7 +46,8 @@
|
|||
|
||||
static struct dhcpc_state s;
|
||||
|
||||
struct dhcp_msg {
|
||||
struct dhcp_msg
|
||||
{
|
||||
u8_t op, htype, hlen, hops;
|
||||
u8_t xid[4];
|
||||
u16_t secs, flags;
|
||||
|
@ -201,8 +202,10 @@ parse_options(u8_t *optptr, int len)
|
|||
u8_t *end = optptr + len;
|
||||
u8_t type = 0;
|
||||
|
||||
while(optptr < end) {
|
||||
switch(*optptr) {
|
||||
while (optptr < end)
|
||||
{
|
||||
switch (*optptr)
|
||||
{
|
||||
case DHCP_OPTION_SUBNET_MASK:
|
||||
memcpy(s.netmask, optptr + 2, 4);
|
||||
break;
|
||||
|
@ -235,9 +238,10 @@ parse_msg(void)
|
|||
{
|
||||
struct dhcp_msg *m = (struct dhcp_msg *)uip_appdata;
|
||||
|
||||
if(m->op == DHCP_REPLY &&
|
||||
if (m->op == DHCP_REPLY &&
|
||||
memcmp(m->xid, xid, sizeof(xid)) == 0 &&
|
||||
memcmp(m->chaddr, s.mac_addr, s.mac_len) == 0) {
|
||||
memcmp(m->chaddr, s.mac_addr, s.mac_len) == 0)
|
||||
{
|
||||
memcpy(s.ipaddr, m->yiaddr, 4);
|
||||
return parse_options(&m->options[4], uip_datalen());
|
||||
}
|
||||
|
@ -253,41 +257,51 @@ PT_THREAD(handle_dhcp(void))
|
|||
s.state = STATE_SENDING;
|
||||
s.ticks = CLOCK_SECOND;
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
send_discover();
|
||||
timer_set(&s.timer, s.ticks);
|
||||
PT_YIELD(&s.pt);
|
||||
PT_WAIT_UNTIL(&s.pt, uip_newdata() || timer_expired(&s.timer));
|
||||
|
||||
if(uip_newdata() && parse_msg() == DHCPOFFER) {
|
||||
if (uip_newdata() && parse_msg() == DHCPOFFER)
|
||||
{
|
||||
s.state = STATE_OFFER_RECEIVED;
|
||||
break;
|
||||
}
|
||||
|
||||
if(s.ticks < CLOCK_SECOND * 60) {
|
||||
if (s.ticks < CLOCK_SECOND * 60)
|
||||
{
|
||||
s.ticks *= 2;
|
||||
}
|
||||
} while(s.state != STATE_OFFER_RECEIVED);
|
||||
}
|
||||
while (s.state != STATE_OFFER_RECEIVED);
|
||||
|
||||
s.ticks = CLOCK_SECOND;
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
send_request();
|
||||
timer_set(&s.timer, s.ticks);
|
||||
PT_YIELD(&s.pt);
|
||||
PT_WAIT_UNTIL(&s.pt, uip_newdata() || timer_expired(&s.timer));
|
||||
|
||||
if(uip_newdata() && parse_msg() == DHCPACK) {
|
||||
if (uip_newdata() && parse_msg() == DHCPACK)
|
||||
{
|
||||
s.state = STATE_CONFIG_RECEIVED;
|
||||
break;
|
||||
}
|
||||
|
||||
if(s.ticks <= CLOCK_SECOND * 10) {
|
||||
if (s.ticks <= CLOCK_SECOND * 10)
|
||||
{
|
||||
s.ticks += CLOCK_SECOND;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
PT_RESTART(&s.pt);
|
||||
}
|
||||
} while(s.state != STATE_CONFIG_RECEIVED);
|
||||
}
|
||||
while (s.state != STATE_CONFIG_RECEIVED);
|
||||
|
||||
#if 0
|
||||
printf("Got IP address %d.%d.%d.%d\n",
|
||||
|
@ -314,7 +328,8 @@ PT_THREAD(handle_dhcp(void))
|
|||
* PT_END restarts the thread so we do this instead. Eventually we
|
||||
* should reacquire expired leases here.
|
||||
*/
|
||||
while(1) {
|
||||
while (1)
|
||||
{
|
||||
PT_YIELD(&s.pt);
|
||||
}
|
||||
|
||||
|
@ -332,7 +347,8 @@ dhcpc_init(const void *mac_addr, int mac_len)
|
|||
s.state = STATE_INITIAL;
|
||||
uip_ipaddr(addr, 255,255,255,255);
|
||||
s.conn = uip_udp_new(&addr, HTONS(DHCPC_SERVER_PORT));
|
||||
if(s.conn != NULL) {
|
||||
if (s.conn != NULL)
|
||||
{
|
||||
uip_udp_bind(s.conn, HTONS(DHCPC_CLIENT_PORT));
|
||||
}
|
||||
PT_INIT(&s.pt);
|
||||
|
@ -349,7 +365,8 @@ dhcpc_request(void)
|
|||
{
|
||||
u16_t ipaddr[2];
|
||||
|
||||
if(s.state == STATE_INITIAL) {
|
||||
if (s.state == STATE_INITIAL)
|
||||
{
|
||||
uip_ipaddr(ipaddr, 0,0,0,0);
|
||||
uip_sethostaddr(ipaddr);
|
||||
/* handle_dhcp(PROCESS_EVENT_NONE, NULL);*/
|
||||
|
|
|
@ -36,7 +36,8 @@
|
|||
#include "uip_timer.h"
|
||||
#include "pt.h"
|
||||
|
||||
struct dhcpc_state {
|
||||
struct dhcpc_state
|
||||
{
|
||||
struct pt pt;
|
||||
char state;
|
||||
struct uip_udp_conn *conn;
|
||||
|
|
|
@ -65,7 +65,8 @@ hello_world_appcall(void)
|
|||
* If a new connection was just established, we should initialize
|
||||
* the protosocket in our applications' state structure.
|
||||
*/
|
||||
if(uip_connected()) {
|
||||
if (uip_connected())
|
||||
{
|
||||
PSOCK_INIT(&s->p, s->inputbuffer, sizeof(s->inputbuffer));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
of our application, and the memory required for this state is
|
||||
allocated together with each TCP connection. One application state
|
||||
for each TCP connection. */
|
||||
typedef struct hello_world_state {
|
||||
typedef struct hello_world_state
|
||||
{
|
||||
struct psock p;
|
||||
char inputbuffer[10];
|
||||
char name[40];
|
||||
|
|
|
@ -68,18 +68,18 @@ struct httpd_state *hs;
|
|||
//
|
||||
//*****************************************************************************
|
||||
static const char page_not_found[] =
|
||||
"HTTP/1.0 404 OK\r\n"
|
||||
"Server: UIP/1.0 (http://www.sics.se/~adam/uip/)\r\n"
|
||||
"Content-type: text/html\r\n\r\n"
|
||||
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd\">"
|
||||
"<html>"
|
||||
"HTTP/1.0 404 OK\r\n"
|
||||
"Server: UIP/1.0 (http://www.sics.se/~adam/uip/)\r\n"
|
||||
"Content-type: text/html\r\n\r\n"
|
||||
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd\">"
|
||||
"<html>"
|
||||
"<head>"
|
||||
"<title>Page Not Found!</title>"
|
||||
"</head>"
|
||||
"<body>"
|
||||
"Page Not Found!"
|
||||
"</body>"
|
||||
"</html>";
|
||||
"</html>";
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
|
@ -88,11 +88,11 @@ static const char page_not_found[] =
|
|||
//
|
||||
//*****************************************************************************
|
||||
static const char default_page_buf1of3[] =
|
||||
"HTTP/1.0 200 OK\r\n"
|
||||
"Server: UIP/1.0 (http://www.sics.se/~adam/uip/)\r\n"
|
||||
"Content-type: text/html\r\n\r\n"
|
||||
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd\">"
|
||||
"<html>"
|
||||
"HTTP/1.0 200 OK\r\n"
|
||||
"Server: UIP/1.0 (http://www.sics.se/~adam/uip/)\r\n"
|
||||
"Content-type: text/html\r\n\r\n"
|
||||
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd\">"
|
||||
"<html>"
|
||||
"<head>"
|
||||
"<title>Welcome to the uIP web server!</title>"
|
||||
"</head>"
|
||||
|
@ -114,7 +114,7 @@ static const char default_page_buf3of3[] =
|
|||
" times since reset!"
|
||||
"</center>"
|
||||
"</body>"
|
||||
"</html>";
|
||||
"</html>";
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
|
@ -130,7 +130,7 @@ httpd_inc_page_count(void)
|
|||
// digit.
|
||||
//
|
||||
default_page_buf2of3[4]++;
|
||||
if(default_page_buf2of3[4] == 0x3a)
|
||||
if (default_page_buf2of3[4] == 0x3a)
|
||||
{
|
||||
default_page_buf2of3[4] = 0x30;
|
||||
default_page_buf2of3[3]++;
|
||||
|
@ -139,7 +139,7 @@ httpd_inc_page_count(void)
|
|||
//
|
||||
// If the 'tens' digit wraps, increment the 'hundreds' digit.
|
||||
//
|
||||
if(default_page_buf2of3[3] == 0x3a)
|
||||
if (default_page_buf2of3[3] == 0x3a)
|
||||
{
|
||||
default_page_buf2of3[3] = 0x30;
|
||||
default_page_buf2of3[2]++;
|
||||
|
@ -148,7 +148,7 @@ httpd_inc_page_count(void)
|
|||
//
|
||||
// If the 'hundreds' digit wraps, increment the 'thousands' digit.
|
||||
//
|
||||
if(default_page_buf2of3[2] == 0x3a)
|
||||
if (default_page_buf2of3[2] == 0x3a)
|
||||
{
|
||||
default_page_buf2of3[2] = 0x30;
|
||||
default_page_buf2of3[1]++;
|
||||
|
@ -157,7 +157,7 @@ httpd_inc_page_count(void)
|
|||
//
|
||||
// If the 'thousands' digit wraps, increment the 'ten-thousands' digit.
|
||||
//
|
||||
if(default_page_buf2of3[1] == 0x3a)
|
||||
if (default_page_buf2of3[1] == 0x3a)
|
||||
{
|
||||
default_page_buf2of3[1] = 0x30;
|
||||
default_page_buf2of3[0]++;
|
||||
|
@ -166,7 +166,7 @@ httpd_inc_page_count(void)
|
|||
//
|
||||
// If the 'ten-thousands' digit wrapped, start over.
|
||||
//
|
||||
if(default_page_buf2of3[0] == 0x3a)
|
||||
if (default_page_buf2of3[0] == 0x3a)
|
||||
{
|
||||
default_page_buf2of3[0] = 0x30;
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ httpd_init(void)
|
|||
void
|
||||
httpd_appcall(void)
|
||||
{
|
||||
switch(uip_conn->lport)
|
||||
switch (uip_conn->lport)
|
||||
{
|
||||
//
|
||||
// This is the web server:
|
||||
|
@ -216,7 +216,7 @@ httpd_appcall(void)
|
|||
// remote host has sent us new data, and if uip_acked() is
|
||||
// non-zero, the remote host has acknowledged the data we
|
||||
// previously sent to it. */
|
||||
if(uip_connected())
|
||||
if (uip_connected())
|
||||
{
|
||||
//
|
||||
// Since we have just been connected with the remote host, we
|
||||
|
@ -230,20 +230,20 @@ httpd_appcall(void)
|
|||
hs->count = 0;
|
||||
return;
|
||||
}
|
||||
else if(uip_poll())
|
||||
else if (uip_poll())
|
||||
{
|
||||
//
|
||||
// If we are polled ten times, we abort the connection. This is
|
||||
// because we don't want connections lingering indefinately in
|
||||
// the system.
|
||||
//
|
||||
if(hs->count++ >= 10)
|
||||
if (hs->count++ >= 10)
|
||||
{
|
||||
uip_abort();
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if(uip_newdata() && hs->state == HTTP_NOGET)
|
||||
else if (uip_newdata() && hs->state == HTTP_NOGET)
|
||||
{
|
||||
//
|
||||
// This is the first data we receive, and it should contain a
|
||||
|
@ -251,7 +251,7 @@ httpd_appcall(void)
|
|||
//
|
||||
// Check for GET.
|
||||
//
|
||||
if(BUF_APPDATA[0] != 'G' ||
|
||||
if (BUF_APPDATA[0] != 'G' ||
|
||||
BUF_APPDATA[1] != 'E' ||
|
||||
BUF_APPDATA[2] != 'T' ||
|
||||
BUF_APPDATA[3] != ' ')
|
||||
|
@ -266,7 +266,7 @@ httpd_appcall(void)
|
|||
//
|
||||
// Check to see what we should send.
|
||||
//
|
||||
if((BUF_APPDATA[4] == '/') &&
|
||||
if ((BUF_APPDATA[4] == '/') &&
|
||||
(BUF_APPDATA[5] == ' '))
|
||||
{
|
||||
//
|
||||
|
@ -282,20 +282,20 @@ httpd_appcall(void)
|
|||
hs->count = 3;
|
||||
}
|
||||
}
|
||||
else if(uip_acked())
|
||||
else if (uip_acked())
|
||||
{
|
||||
hs->count++;
|
||||
if(hs->count == 1)
|
||||
if (hs->count == 1)
|
||||
{
|
||||
uip_send(default_page_buf2of3,
|
||||
sizeof(default_page_buf2of3) - 1);
|
||||
}
|
||||
else if(hs->count == 2)
|
||||
else if (hs->count == 2)
|
||||
{
|
||||
uip_send(default_page_buf3of3,
|
||||
sizeof(default_page_buf3of3) - 1);
|
||||
}
|
||||
else if(hs->count == 3)
|
||||
else if (hs->count == 3)
|
||||
{
|
||||
httpd_inc_page_count();
|
||||
uip_close();
|
||||
|
|
|
@ -73,7 +73,8 @@
|
|||
#define MAX_RETRIES 8
|
||||
|
||||
/** \internal The DNS message header. */
|
||||
struct dns_hdr {
|
||||
struct dns_hdr
|
||||
{
|
||||
u16_t id;
|
||||
u8_t flags1, flags2;
|
||||
#define DNS_FLAG1_RESPONSE 0x80
|
||||
|
@ -94,7 +95,8 @@ struct dns_hdr {
|
|||
};
|
||||
|
||||
/** \internal The DNS answer message structure. */
|
||||
struct dns_answer {
|
||||
struct dns_answer
|
||||
{
|
||||
/* DNS answer record starts with either a domain name or a pointer
|
||||
to a name already present somewhere in the packet. */
|
||||
u16_t type;
|
||||
|
@ -104,7 +106,8 @@ struct dns_answer {
|
|||
uip_ipaddr_t ipaddr;
|
||||
};
|
||||
|
||||
struct namemap {
|
||||
struct namemap
|
||||
{
|
||||
#define STATE_UNUSED 0
|
||||
#define STATE_NEW 1
|
||||
#define STATE_ASKING 2
|
||||
|
@ -145,16 +148,19 @@ parse_name(unsigned char *query)
|
|||
{
|
||||
unsigned char n;
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
n = *query++;
|
||||
|
||||
while(n > 0) {
|
||||
while (n > 0)
|
||||
{
|
||||
/* printf("%c", *query);*/
|
||||
++query;
|
||||
--n;
|
||||
};
|
||||
/* printf(".");*/
|
||||
} while(*query != 0);
|
||||
}
|
||||
while (*query != 0);
|
||||
/* printf("\n");*/
|
||||
return query + 1;
|
||||
}
|
||||
|
@ -173,25 +179,34 @@ check_entries(void)
|
|||
static u8_t n;
|
||||
register struct namemap *namemapptr;
|
||||
|
||||
for(i = 0; i < RESOLV_ENTRIES; ++i) {
|
||||
for (i = 0; i < RESOLV_ENTRIES; ++i)
|
||||
{
|
||||
namemapptr = &names[i];
|
||||
if(namemapptr->state == STATE_NEW ||
|
||||
namemapptr->state == STATE_ASKING) {
|
||||
if(namemapptr->state == STATE_ASKING) {
|
||||
if(--namemapptr->tmr == 0) {
|
||||
if(++namemapptr->retries == MAX_RETRIES) {
|
||||
if (namemapptr->state == STATE_NEW ||
|
||||
namemapptr->state == STATE_ASKING)
|
||||
{
|
||||
if (namemapptr->state == STATE_ASKING)
|
||||
{
|
||||
if (--namemapptr->tmr == 0)
|
||||
{
|
||||
if (++namemapptr->retries == MAX_RETRIES)
|
||||
{
|
||||
namemapptr->state = STATE_ERROR;
|
||||
resolv_found(namemapptr->name, NULL);
|
||||
continue;
|
||||
}
|
||||
namemapptr->tmr = namemapptr->retries;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* printf("Timer %d\n", namemapptr->tmr);*/
|
||||
/* Its timer has not run out, so we move on to next
|
||||
entry. */
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
namemapptr->state = STATE_ASKING;
|
||||
namemapptr->tmr = 1;
|
||||
namemapptr->retries = 0;
|
||||
|
@ -205,17 +220,20 @@ check_entries(void)
|
|||
nameptr = namemapptr->name;
|
||||
--nameptr;
|
||||
/* Convert hostname into suitable query format. */
|
||||
do {
|
||||
do
|
||||
{
|
||||
++nameptr;
|
||||
nptr = query;
|
||||
++query;
|
||||
for(n = 0; *nameptr != '.' && *nameptr != 0; ++nameptr) {
|
||||
for (n = 0; *nameptr != '.' && *nameptr != 0; ++nameptr)
|
||||
{
|
||||
*query = *nameptr;
|
||||
++query;
|
||||
++n;
|
||||
}
|
||||
*nptr = n;
|
||||
} while(*nameptr != 0);
|
||||
}
|
||||
while (*nameptr != 0);
|
||||
{
|
||||
static unsigned char endquery[] =
|
||||
{0,0,1,0,1};
|
||||
|
@ -256,15 +274,17 @@ newdata(void)
|
|||
table. */
|
||||
i = htons(hdr->id);
|
||||
namemapptr = &names[i];
|
||||
if(i < RESOLV_ENTRIES &&
|
||||
namemapptr->state == STATE_ASKING) {
|
||||
if (i < RESOLV_ENTRIES &&
|
||||
namemapptr->state == STATE_ASKING)
|
||||
{
|
||||
|
||||
/* This entry is now finished. */
|
||||
namemapptr->state = STATE_DONE;
|
||||
namemapptr->err = hdr->flags2 & DNS_FLAG2_ERR_MASK;
|
||||
|
||||
/* Check for error. If so, call callback to inform. */
|
||||
if(namemapptr->err != 0) {
|
||||
if (namemapptr->err != 0)
|
||||
{
|
||||
namemapptr->state = STATE_ERROR;
|
||||
resolv_found(namemapptr->name, NULL);
|
||||
return;
|
||||
|
@ -280,14 +300,18 @@ newdata(void)
|
|||
match. */
|
||||
nameptr = parse_name((char *)uip_appdata + 12) + 4;
|
||||
|
||||
while(nanswers > 0) {
|
||||
while (nanswers > 0)
|
||||
{
|
||||
/* The first byte in the answer resource record determines if it
|
||||
is a compressed record or a normal one. */
|
||||
if(*nameptr & 0xc0) {
|
||||
if (*nameptr & 0xc0)
|
||||
{
|
||||
/* Compressed name. */
|
||||
nameptr +=2;
|
||||
/* printf("Compressed anwser\n");*/
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Not compressed name. */
|
||||
nameptr = parse_name((char *)nameptr);
|
||||
}
|
||||
|
@ -299,9 +323,10 @@ newdata(void)
|
|||
|
||||
/* Check for IP address type and Internet class. Others are
|
||||
discarded. */
|
||||
if(ans->type == HTONS(1) &&
|
||||
if (ans->type == HTONS(1) &&
|
||||
ans->class == HTONS(1) &&
|
||||
ans->len == HTONS(4)) {
|
||||
ans->len == HTONS(4))
|
||||
{
|
||||
/* printf("IP address %d.%d.%d.%d\n",
|
||||
htons(ans->ipaddr[0]) >> 8,
|
||||
htons(ans->ipaddr[0]) & 0xff,
|
||||
|
@ -314,7 +339,9 @@ newdata(void)
|
|||
|
||||
resolv_found(namemapptr->name, namemapptr->ipaddr);
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
nameptr = nameptr + 10 + htons(ans->len);
|
||||
}
|
||||
--nanswers;
|
||||
|
@ -330,11 +357,14 @@ newdata(void)
|
|||
void
|
||||
resolv_appcall(void)
|
||||
{
|
||||
if(uip_udp_conn->rport == HTONS(53)) {
|
||||
if(uip_poll()) {
|
||||
if (uip_udp_conn->rport == HTONS(53))
|
||||
{
|
||||
if (uip_poll())
|
||||
{
|
||||
check_entries();
|
||||
}
|
||||
if(uip_newdata()) {
|
||||
if (uip_newdata())
|
||||
{
|
||||
newdata();
|
||||
}
|
||||
}
|
||||
|
@ -355,18 +385,22 @@ resolv_query(char *name)
|
|||
|
||||
lseq = lseqi = 0;
|
||||
|
||||
for(i = 0; i < RESOLV_ENTRIES; ++i) {
|
||||
for (i = 0; i < RESOLV_ENTRIES; ++i)
|
||||
{
|
||||
nameptr = &names[i];
|
||||
if(nameptr->state == STATE_UNUSED) {
|
||||
if (nameptr->state == STATE_UNUSED)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(seqno - nameptr->seqno > lseq) {
|
||||
if (seqno - nameptr->seqno > lseq)
|
||||
{
|
||||
lseq = seqno - nameptr->seqno;
|
||||
lseqi = i;
|
||||
}
|
||||
}
|
||||
|
||||
if(i == RESOLV_ENTRIES) {
|
||||
if (i == RESOLV_ENTRIES)
|
||||
{
|
||||
i = lseqi;
|
||||
nameptr = &names[i];
|
||||
}
|
||||
|
@ -400,10 +434,12 @@ resolv_lookup(char *name)
|
|||
|
||||
/* Walk through the list to see if the name is in there. If it is
|
||||
not, we return NULL. */
|
||||
for(i = 0; i < RESOLV_ENTRIES; ++i) {
|
||||
for (i = 0; i < RESOLV_ENTRIES; ++i)
|
||||
{
|
||||
nameptr = &names[i];
|
||||
if(nameptr->state == STATE_DONE &&
|
||||
strcmp(name, nameptr->name) == 0) {
|
||||
if (nameptr->state == STATE_DONE &&
|
||||
strcmp(name, nameptr->name) == 0)
|
||||
{
|
||||
return nameptr->ipaddr;
|
||||
}
|
||||
}
|
||||
|
@ -421,7 +457,8 @@ resolv_lookup(char *name)
|
|||
u16_t *
|
||||
resolv_getserver(void)
|
||||
{
|
||||
if(resolv_conn == NULL) {
|
||||
if (resolv_conn == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return resolv_conn->ripaddr;
|
||||
|
@ -437,7 +474,8 @@ resolv_getserver(void)
|
|||
void
|
||||
resolv_conf(u16_t *dnsserver)
|
||||
{
|
||||
if(resolv_conn != NULL) {
|
||||
if (resolv_conn != NULL)
|
||||
{
|
||||
uip_udp_remove(resolv_conn);
|
||||
}
|
||||
|
||||
|
@ -453,7 +491,8 @@ resolv_init(void)
|
|||
{
|
||||
static u8_t i;
|
||||
|
||||
for(i = 0; i < RESOLV_ENTRIES; ++i) {
|
||||
for (i = 0; i < RESOLV_ENTRIES; ++i)
|
||||
{
|
||||
names[i].state = STATE_DONE;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,38 +33,38 @@
|
|||
* $Id: smtp-strings.c,v 1.3 2006/06/11 21:46:37 adam Exp $
|
||||
*/
|
||||
const char smtp_220[4] =
|
||||
/* "220" */
|
||||
/* "220" */
|
||||
{0x32, 0x32, 0x30, };
|
||||
const char smtp_helo[6] =
|
||||
/* "HELO " */
|
||||
/* "HELO " */
|
||||
{0x48, 0x45, 0x4c, 0x4f, 0x20, };
|
||||
const char smtp_mail_from[12] =
|
||||
/* "MAIL FROM: " */
|
||||
/* "MAIL FROM: " */
|
||||
{0x4d, 0x41, 0x49, 0x4c, 0x20, 0x46, 0x52, 0x4f, 0x4d, 0x3a, 0x20, };
|
||||
const char smtp_rcpt_to[10] =
|
||||
/* "RCPT TO: " */
|
||||
/* "RCPT TO: " */
|
||||
{0x52, 0x43, 0x50, 0x54, 0x20, 0x54, 0x4f, 0x3a, 0x20, };
|
||||
const char smtp_data[7] =
|
||||
/* "DATA\r\n" */
|
||||
/* "DATA\r\n" */
|
||||
{0x44, 0x41, 0x54, 0x41, 0xd, 0xa, };
|
||||
const char smtp_to[5] =
|
||||
/* "To: " */
|
||||
/* "To: " */
|
||||
{0x54, 0x6f, 0x3a, 0x20, };
|
||||
const char smtp_cc[5] =
|
||||
/* "Cc: " */
|
||||
/* "Cc: " */
|
||||
{0x43, 0x63, 0x3a, 0x20, };
|
||||
const char smtp_from[7] =
|
||||
/* "From: " */
|
||||
/* "From: " */
|
||||
{0x46, 0x72, 0x6f, 0x6d, 0x3a, 0x20, };
|
||||
const char smtp_subject[10] =
|
||||
/* "Subject: " */
|
||||
/* "Subject: " */
|
||||
{0x53, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x3a, 0x20, };
|
||||
const char smtp_quit[7] =
|
||||
/* "QUIT\r\n" */
|
||||
/* "QUIT\r\n" */
|
||||
{0x51, 0x55, 0x49, 0x54, 0xd, 0xa, };
|
||||
const char smtp_crnl[3] =
|
||||
/* "\r\n" */
|
||||
/* "\r\n" */
|
||||
{0xd, 0xa, };
|
||||
const char smtp_crnlperiodcrnl[6] =
|
||||
/* "\r\n.\r\n" */
|
||||
/* "\r\n.\r\n" */
|
||||
{0xd, 0xa, 0x2e, 0xd, 0xa, };
|
||||
|
|
|
@ -86,7 +86,8 @@ PT_THREAD(smtp_thread(void))
|
|||
|
||||
PSOCK_READTO(&s.psock, ISO_nl);
|
||||
|
||||
if(strncmp(s.inputbuffer, smtp_220, 3) != 0) {
|
||||
if (strncmp(s.inputbuffer, smtp_220, 3) != 0)
|
||||
{
|
||||
PSOCK_CLOSE(&s.psock);
|
||||
smtp_done(2);
|
||||
PSOCK_EXIT(&s.psock);
|
||||
|
@ -98,7 +99,8 @@ PT_THREAD(smtp_thread(void))
|
|||
|
||||
PSOCK_READTO(&s.psock, ISO_nl);
|
||||
|
||||
if(s.inputbuffer[0] != ISO_2) {
|
||||
if (s.inputbuffer[0] != ISO_2)
|
||||
{
|
||||
PSOCK_CLOSE(&s.psock);
|
||||
smtp_done(3);
|
||||
PSOCK_EXIT(&s.psock);
|
||||
|
@ -110,7 +112,8 @@ PT_THREAD(smtp_thread(void))
|
|||
|
||||
PSOCK_READTO(&s.psock, ISO_nl);
|
||||
|
||||
if(s.inputbuffer[0] != ISO_2) {
|
||||
if (s.inputbuffer[0] != ISO_2)
|
||||
{
|
||||
PSOCK_CLOSE(&s.psock);
|
||||
smtp_done(4);
|
||||
PSOCK_EXIT(&s.psock);
|
||||
|
@ -122,20 +125,23 @@ PT_THREAD(smtp_thread(void))
|
|||
|
||||
PSOCK_READTO(&s.psock, ISO_nl);
|
||||
|
||||
if(s.inputbuffer[0] != ISO_2) {
|
||||
if (s.inputbuffer[0] != ISO_2)
|
||||
{
|
||||
PSOCK_CLOSE(&s.psock);
|
||||
smtp_done(5);
|
||||
PSOCK_EXIT(&s.psock);
|
||||
}
|
||||
|
||||
if(s.cc != 0) {
|
||||
if (s.cc != 0)
|
||||
{
|
||||
PSOCK_SEND_STR(&s.psock, (char *)smtp_rcpt_to);
|
||||
PSOCK_SEND_STR(&s.psock, s.cc);
|
||||
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
|
||||
|
||||
PSOCK_READTO(&s.psock, ISO_nl);
|
||||
|
||||
if(s.inputbuffer[0] != ISO_2) {
|
||||
if (s.inputbuffer[0] != ISO_2)
|
||||
{
|
||||
PSOCK_CLOSE(&s.psock);
|
||||
smtp_done(6);
|
||||
PSOCK_EXIT(&s.psock);
|
||||
|
@ -146,7 +152,8 @@ PT_THREAD(smtp_thread(void))
|
|||
|
||||
PSOCK_READTO(&s.psock, ISO_nl);
|
||||
|
||||
if(s.inputbuffer[0] != ISO_3) {
|
||||
if (s.inputbuffer[0] != ISO_3)
|
||||
{
|
||||
PSOCK_CLOSE(&s.psock);
|
||||
smtp_done(7);
|
||||
PSOCK_EXIT(&s.psock);
|
||||
|
@ -156,7 +163,8 @@ PT_THREAD(smtp_thread(void))
|
|||
PSOCK_SEND_STR(&s.psock, s.to);
|
||||
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
|
||||
|
||||
if(s.cc != 0) {
|
||||
if (s.cc != 0)
|
||||
{
|
||||
PSOCK_SEND_STR(&s.psock, (char *)smtp_cc);
|
||||
PSOCK_SEND_STR(&s.psock, s.cc);
|
||||
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnl);
|
||||
|
@ -175,7 +183,8 @@ PT_THREAD(smtp_thread(void))
|
|||
PSOCK_SEND_STR(&s.psock, (char *)smtp_crnlperiodcrnl);
|
||||
|
||||
PSOCK_READTO(&s.psock, ISO_nl);
|
||||
if(s.inputbuffer[0] != ISO_2) {
|
||||
if (s.inputbuffer[0] != ISO_2)
|
||||
{
|
||||
PSOCK_CLOSE(&s.psock);
|
||||
smtp_done(8);
|
||||
PSOCK_EXIT(&s.psock);
|
||||
|
@ -189,11 +198,13 @@ PT_THREAD(smtp_thread(void))
|
|||
void
|
||||
smtp_appcall(void)
|
||||
{
|
||||
if(uip_closed()) {
|
||||
if (uip_closed())
|
||||
{
|
||||
s.connected = 0;
|
||||
return;
|
||||
}
|
||||
if(uip_aborted() || uip_timedout()) {
|
||||
if (uip_aborted() || uip_timedout())
|
||||
{
|
||||
s.connected = 0;
|
||||
smtp_done(1);
|
||||
return;
|
||||
|
@ -236,7 +247,8 @@ smtp_send(char *to, char *cc, char *from,
|
|||
struct uip_conn *conn;
|
||||
|
||||
conn = uip_connect(smtpserver, HTONS(25));
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
s.connected = 1;
|
||||
|
|
|
@ -78,7 +78,8 @@ unsigned char smtp_send(char *to, char *from,
|
|||
|
||||
void smtp_appcall(void);
|
||||
|
||||
struct smtp_state {
|
||||
struct smtp_state
|
||||
{
|
||||
u8_t state;
|
||||
char *to;
|
||||
char *from;
|
||||
|
|
|
@ -1,42 +1,43 @@
|
|||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: shell.c,v 1.1 2006/06/07 09:43:54 adam Exp $
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2003, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the uIP TCP/IP stack.
|
||||
*
|
||||
* $Id: shell.c,v 1.1 2006/06/07 09:43:54 adam Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shell.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
struct ptentry {
|
||||
struct ptentry
|
||||
{
|
||||
char *commandstr;
|
||||
void (* pfunc)(char *str);
|
||||
};
|
||||
|
@ -48,8 +49,10 @@ static void
|
|||
parse(register char *str, struct ptentry *t)
|
||||
{
|
||||
struct ptentry *p;
|
||||
for(p = t; p->commandstr != NULL; ++p) {
|
||||
if(strncmp(p->commandstr, str, strlen(p->commandstr)) == 0) {
|
||||
for (p = t; p->commandstr != NULL; ++p)
|
||||
{
|
||||
if (strncmp(p->commandstr, str, strlen(p->commandstr)) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -61,11 +64,13 @@ static void
|
|||
inttostr(register char *str, unsigned int i)
|
||||
{
|
||||
str[0] = '0' + i / 100;
|
||||
if(str[0] == '0') {
|
||||
if (str[0] == '0')
|
||||
{
|
||||
str[0] = ' ';
|
||||
}
|
||||
str[1] = '0' + (i / 10) % 10;
|
||||
if(str[0] == ' ' && str[1] == '0') {
|
||||
if (str[0] == ' ' && str[1] == '0')
|
||||
{
|
||||
str[1] = ' ';
|
||||
}
|
||||
str[2] = '0' + i % 10;
|
||||
|
@ -86,20 +91,23 @@ help(char *str)
|
|||
static void
|
||||
unknown(char *str)
|
||||
{
|
||||
if(strlen(str) > 0) {
|
||||
if (strlen(str) > 0)
|
||||
{
|
||||
shell_output("Unknown command: ", str);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static struct ptentry parsetab[] =
|
||||
{{"stats", help},
|
||||
{
|
||||
{"stats", help},
|
||||
{"conn", help},
|
||||
{"help", help},
|
||||
{"exit", shell_quit},
|
||||
{"?", help},
|
||||
|
||||
/* Default action */
|
||||
{NULL, unknown}};
|
||||
{NULL, unknown}
|
||||
};
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
shell_init(void)
|
||||
|
|
|
@ -42,7 +42,8 @@
|
|||
#define ISO_nl 0x0a
|
||||
#define ISO_cr 0x0d
|
||||
|
||||
struct telnetd_line {
|
||||
struct telnetd_line
|
||||
{
|
||||
char line[TELNETD_CONF_LINELEN];
|
||||
};
|
||||
MEMB(linemem, struct telnetd_line, TELNETD_CONF_NUMLINES);
|
||||
|
@ -86,13 +87,16 @@ sendline(char *line)
|
|||
{
|
||||
static unsigned int i;
|
||||
|
||||
for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
|
||||
if(s.lines[i] == NULL) {
|
||||
for (i = 0; i < TELNETD_CONF_NUMLINES; ++i)
|
||||
{
|
||||
if (s.lines[i] == NULL)
|
||||
{
|
||||
s.lines[i] = line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i == TELNETD_CONF_NUMLINES) {
|
||||
if (i == TELNETD_CONF_NUMLINES)
|
||||
{
|
||||
dealloc_line(line);
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +106,8 @@ shell_prompt(char *str)
|
|||
{
|
||||
char *line;
|
||||
line = alloc_line();
|
||||
if(line != NULL) {
|
||||
if (line != NULL)
|
||||
{
|
||||
strncpy(line, str, TELNETD_CONF_LINELEN);
|
||||
/* petsciiconv_toascii(line, TELNETD_CONF_LINELEN);*/
|
||||
sendline(line);
|
||||
|
@ -116,14 +121,17 @@ shell_output(char *str1, char *str2)
|
|||
char *line;
|
||||
|
||||
line = alloc_line();
|
||||
if(line != NULL) {
|
||||
if (line != NULL)
|
||||
{
|
||||
len = strlen(str1);
|
||||
strncpy(line, str1, TELNETD_CONF_LINELEN);
|
||||
if(len < TELNETD_CONF_LINELEN) {
|
||||
if (len < TELNETD_CONF_LINELEN)
|
||||
{
|
||||
strncpy(line + len, str2, TELNETD_CONF_LINELEN - len);
|
||||
}
|
||||
len = strlen(line);
|
||||
if(len < TELNETD_CONF_LINELEN - 2) {
|
||||
if (len < TELNETD_CONF_LINELEN - 2)
|
||||
{
|
||||
line[len] = ISO_cr;
|
||||
line[len+1] = ISO_nl;
|
||||
line[len+2] = 0;
|
||||
|
@ -146,9 +154,11 @@ acked(void)
|
|||
{
|
||||
static unsigned int i;
|
||||
|
||||
while(s.numsent > 0) {
|
||||
while (s.numsent > 0)
|
||||
{
|
||||
dealloc_line(s.lines[0]);
|
||||
for(i = 1; i < TELNETD_CONF_NUMLINES; ++i) {
|
||||
for (i = 1; i < TELNETD_CONF_NUMLINES; ++i)
|
||||
{
|
||||
s.lines[i - 1] = s.lines[i];
|
||||
}
|
||||
s.lines[TELNETD_CONF_NUMLINES - 1] = NULL;
|
||||
|
@ -164,18 +174,23 @@ senddata(void)
|
|||
|
||||
bufptr = uip_appdata;
|
||||
buflen = 0;
|
||||
for(s.numsent = 0; s.numsent < TELNETD_CONF_NUMLINES &&
|
||||
s.lines[s.numsent] != NULL ; ++s.numsent) {
|
||||
for (s.numsent = 0; s.numsent < TELNETD_CONF_NUMLINES &&
|
||||
s.lines[s.numsent] != NULL ; ++s.numsent)
|
||||
{
|
||||
lineptr = s.lines[s.numsent];
|
||||
linelen = strlen(lineptr);
|
||||
if(linelen > TELNETD_CONF_LINELEN) {
|
||||
if (linelen > TELNETD_CONF_LINELEN)
|
||||
{
|
||||
linelen = TELNETD_CONF_LINELEN;
|
||||
}
|
||||
if(buflen + linelen < uip_mss()) {
|
||||
if (buflen + linelen < uip_mss())
|
||||
{
|
||||
memcpy(bufptr, lineptr, linelen);
|
||||
bufptr += linelen;
|
||||
buflen += linelen;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -187,8 +202,10 @@ closed(void)
|
|||
{
|
||||
static unsigned int i;
|
||||
|
||||
for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
|
||||
if(s.lines[i] != NULL) {
|
||||
for (i = 0; i < TELNETD_CONF_NUMLINES; ++i)
|
||||
{
|
||||
if (s.lines[i] != NULL)
|
||||
{
|
||||
dealloc_line(s.lines[i]);
|
||||
}
|
||||
}
|
||||
|
@ -197,20 +214,25 @@ closed(void)
|
|||
static void
|
||||
get_char(u8_t c)
|
||||
{
|
||||
if(c == ISO_cr) {
|
||||
if (c == ISO_cr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
s.buf[(int)s.bufptr] = c;
|
||||
if(s.buf[(int)s.bufptr] == ISO_nl ||
|
||||
s.bufptr == sizeof(s.buf) - 1) {
|
||||
if(s.bufptr > 0) {
|
||||
if (s.buf[(int)s.bufptr] == ISO_nl ||
|
||||
s.bufptr == sizeof(s.buf) - 1)
|
||||
{
|
||||
if (s.bufptr > 0)
|
||||
{
|
||||
s.buf[(int)s.bufptr] = 0;
|
||||
/* petsciiconv_topetscii(s.buf, TELNETD_CONF_LINELEN);*/
|
||||
}
|
||||
shell_input(s.buf);
|
||||
s.bufptr = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
++s.bufptr;
|
||||
}
|
||||
}
|
||||
|
@ -220,7 +242,8 @@ sendopt(u8_t option, u8_t value)
|
|||
{
|
||||
char *line;
|
||||
line = alloc_line();
|
||||
if(line != NULL) {
|
||||
if (line != NULL)
|
||||
{
|
||||
line[0] = TELNET_IAC;
|
||||
line[1] = option;
|
||||
line[2] = value;
|
||||
|
@ -240,17 +263,23 @@ newdata(void)
|
|||
len = uip_datalen();
|
||||
dataptr = (char *)uip_appdata;
|
||||
|
||||
while(len > 0 && s.bufptr < sizeof(s.buf)) {
|
||||
while (len > 0 && s.bufptr < sizeof(s.buf))
|
||||
{
|
||||
c = *dataptr;
|
||||
++dataptr;
|
||||
--len;
|
||||
switch(s.state) {
|
||||
switch (s.state)
|
||||
{
|
||||
case STATE_IAC:
|
||||
if(c == TELNET_IAC) {
|
||||
if (c == TELNET_IAC)
|
||||
{
|
||||
get_char(c);
|
||||
s.state = STATE_NORMAL;
|
||||
} else {
|
||||
switch(c) {
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case TELNET_WILL:
|
||||
s.state = STATE_WILL;
|
||||
break;
|
||||
|
@ -291,9 +320,12 @@ newdata(void)
|
|||
s.state = STATE_NORMAL;
|
||||
break;
|
||||
case STATE_NORMAL:
|
||||
if(c == TELNET_IAC) {
|
||||
if (c == TELNET_IAC)
|
||||
{
|
||||
s.state = STATE_IAC;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
get_char(c);
|
||||
}
|
||||
break;
|
||||
|
@ -308,9 +340,11 @@ void
|
|||
telnetd_appcall(void)
|
||||
{
|
||||
static unsigned int i;
|
||||
if(uip_connected()) {
|
||||
if (uip_connected())
|
||||
{
|
||||
/* tcp_markconn(uip_conn, &s);*/
|
||||
for(i = 0; i < TELNETD_CONF_NUMLINES; ++i) {
|
||||
for (i = 0; i < TELNETD_CONF_NUMLINES; ++i)
|
||||
{
|
||||
s.lines[i] = NULL;
|
||||
}
|
||||
s.bufptr = 0;
|
||||
|
@ -319,31 +353,36 @@ telnetd_appcall(void)
|
|||
shell_start();
|
||||
}
|
||||
|
||||
if(s.state == STATE_CLOSE) {
|
||||
if (s.state == STATE_CLOSE)
|
||||
{
|
||||
s.state = STATE_NORMAL;
|
||||
uip_close();
|
||||
return;
|
||||
}
|
||||
|
||||
if(uip_closed() ||
|
||||
if (uip_closed() ||
|
||||
uip_aborted() ||
|
||||
uip_timedout()) {
|
||||
uip_timedout())
|
||||
{
|
||||
closed();
|
||||
}
|
||||
|
||||
if(uip_acked()) {
|
||||
if (uip_acked())
|
||||
{
|
||||
acked();
|
||||
}
|
||||
|
||||
if(uip_newdata()) {
|
||||
if (uip_newdata())
|
||||
{
|
||||
newdata();
|
||||
}
|
||||
|
||||
if(uip_rexmit() ||
|
||||
if (uip_rexmit() ||
|
||||
uip_newdata() ||
|
||||
uip_acked() ||
|
||||
uip_connected() ||
|
||||
uip_poll()) {
|
||||
uip_poll())
|
||||
{
|
||||
senddata();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,8 @@ void telnetd_appcall(void);
|
|||
#define TELNETD_CONF_NUMLINES 16
|
||||
#endif
|
||||
|
||||
struct telnetd_state {
|
||||
struct telnetd_state
|
||||
{
|
||||
char *lines[TELNETD_CONF_NUMLINES];
|
||||
char buf[TELNETD_CONF_LINELEN];
|
||||
char bufptr;
|
||||
|
|
|
@ -1,93 +1,93 @@
|
|||
const char http_http[8] =
|
||||
/* "http://" */
|
||||
/* "http://" */
|
||||
{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0 };
|
||||
const char http_200[5] =
|
||||
/* "200 " */
|
||||
/* "200 " */
|
||||
{0x32, 0x30, 0x30, 0x20, 0 };
|
||||
const char http_301[5] =
|
||||
/* "301 " */
|
||||
/* "301 " */
|
||||
{0x33, 0x30, 0x31, 0x20, 0 };
|
||||
const char http_302[5] =
|
||||
/* "302 " */
|
||||
/* "302 " */
|
||||
{0x33, 0x30, 0x32, 0x20, 0 };
|
||||
const char http_get[5] =
|
||||
/* "GET " */
|
||||
/* "GET " */
|
||||
{0x47, 0x45, 0x54, 0x20, 0 };
|
||||
const char http_10[9] =
|
||||
/* "HTTP/1.0" */
|
||||
/* "HTTP/1.0" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0 };
|
||||
const char http_11[9] =
|
||||
/* "HTTP/1.1" */
|
||||
/* "HTTP/1.1" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0 };
|
||||
const char http_content_type[15] =
|
||||
/* "content-type: " */
|
||||
/* "content-type: " */
|
||||
{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0 };
|
||||
const char http_texthtml[10] =
|
||||
/* "text/html" */
|
||||
/* "text/html" */
|
||||
{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0 };
|
||||
const char http_location[11] =
|
||||
/* "location: " */
|
||||
/* "location: " */
|
||||
{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0 };
|
||||
const char http_host[7] =
|
||||
/* "host: " */
|
||||
/* "host: " */
|
||||
{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, 0 };
|
||||
const char http_crnl[3] =
|
||||
/* "\r\n" */
|
||||
/* "\r\n" */
|
||||
{0xd, 0xa, 0 };
|
||||
const char http_index_html[12] =
|
||||
/* "/index.html" */
|
||||
/* "/index.html" */
|
||||
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
|
||||
const char http_404_html[10] =
|
||||
/* "/404.html" */
|
||||
/* "/404.html" */
|
||||
{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
|
||||
const char http_content_type_html[28] =
|
||||
/* "Content-type: text/html\r\n\r\n" */
|
||||
/* "Content-type: text/html\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
const char http_content_type_css [27] =
|
||||
/* "Content-type: text/css\r\n\r\n" */
|
||||
/* "Content-type: text/css\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
const char http_content_type_text[28] =
|
||||
/* "Content-type: text/text\r\n\r\n" */
|
||||
/* "Content-type: text/text\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
const char http_content_type_png [28] =
|
||||
/* "Content-type: image/png\r\n\r\n" */
|
||||
/* "Content-type: image/png\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
const char http_content_type_gif [28] =
|
||||
/* "Content-type: image/gif\r\n\r\n" */
|
||||
/* "Content-type: image/gif\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
const char http_content_type_jpg [29] =
|
||||
/* "Content-type: image/jpeg\r\n\r\n" */
|
||||
/* "Content-type: image/jpeg\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
const char http_content_type_binary[43] =
|
||||
/* "Content-type: application/octet-stream\r\n\r\n" */
|
||||
/* "Content-type: application/octet-stream\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
const char http_html[6] =
|
||||
/* ".html" */
|
||||
/* ".html" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, 0x6c, 0 };
|
||||
const char http_shtml[7] =
|
||||
/* ".shtml" */
|
||||
/* ".shtml" */
|
||||
{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0 };
|
||||
const char http_htm[5] =
|
||||
/* ".htm" */
|
||||
/* ".htm" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, 0 };
|
||||
const char http_css[5] =
|
||||
/* ".css" */
|
||||
/* ".css" */
|
||||
{0x2e, 0x63, 0x73, 0x73, 0 };
|
||||
const char http_png[5] =
|
||||
/* ".png" */
|
||||
/* ".png" */
|
||||
{0x2e, 0x70, 0x6e, 0x67, 0 };
|
||||
const char http_gif[5] =
|
||||
/* ".gif" */
|
||||
/* ".gif" */
|
||||
{0x2e, 0x67, 0x69, 0x66, 0 };
|
||||
const char http_jpg[5] =
|
||||
/* ".jpg" */
|
||||
/* ".jpg" */
|
||||
{0x2e, 0x6a, 0x70, 0x67, 0 };
|
||||
const char http_text[6] =
|
||||
/* ".text" */
|
||||
/* ".text" */
|
||||
{0x2e, 0x74, 0x65, 0x78, 0x74, 0 };
|
||||
const char http_txt[5] =
|
||||
/* ".txt" */
|
||||
/* ".txt" */
|
||||
{0x2e, 0x74, 0x78, 0x74, 0 };
|
||||
const char http_user_agent_fields[77] =
|
||||
/* "Connection: close\r\nUser-Agent: uIP/1.0 (; http://www.sics.se/~adam/uip/)\r\n\r\n" */
|
||||
/* "Connection: close\r\nUser-Agent: uIP/1.0 (; http://www.sics.se/~adam/uip/)\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x28, 0x3b, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0x29, 0xd, 0xa, 0xd, 0xa, 0 };
|
||||
|
|
|
@ -145,17 +145,20 @@ webclient_get(char *host, u16_t port, char *file)
|
|||
|
||||
/* First check if the host is an IP address. */
|
||||
ipaddr = &addr;
|
||||
if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {
|
||||
if (uiplib_ipaddrconv(host, (unsigned char *)addr) == 0)
|
||||
{
|
||||
ipaddr = (uip_ipaddr_t *)resolv_lookup(host);
|
||||
|
||||
if(ipaddr == NULL) {
|
||||
if (ipaddr == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
conn = uip_connect(ipaddr, htons(port));
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -182,7 +185,8 @@ senddata(void)
|
|||
char *getrequest;
|
||||
char *cptr;
|
||||
|
||||
if(s.getrequestleft > 0) {
|
||||
if (s.getrequestleft > 0)
|
||||
{
|
||||
cptr = getrequest = (char *)uip_appdata;
|
||||
|
||||
cptr = copy_string(cptr, http_get, sizeof(http_get) - 1);
|
||||
|
@ -211,7 +215,8 @@ acked(void)
|
|||
{
|
||||
u16_t len;
|
||||
|
||||
if(s.getrequestleft > 0) {
|
||||
if (s.getrequestleft > 0)
|
||||
{
|
||||
len = s.getrequestleft > uip_mss()?
|
||||
uip_mss():
|
||||
s.getrequestleft;
|
||||
|
@ -225,30 +230,40 @@ parse_statusline(u16_t len)
|
|||
{
|
||||
char *cptr;
|
||||
|
||||
while(len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline)) {
|
||||
while (len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline))
|
||||
{
|
||||
s.httpheaderline[s.httpheaderlineptr] = *(char *)uip_appdata;
|
||||
++((char *)uip_appdata);
|
||||
--len;
|
||||
if(s.httpheaderline[s.httpheaderlineptr] == ISO_nl) {
|
||||
if (s.httpheaderline[s.httpheaderlineptr] == ISO_nl)
|
||||
{
|
||||
|
||||
if((strncmp(s.httpheaderline, http_10,
|
||||
if ((strncmp(s.httpheaderline, http_10,
|
||||
sizeof(http_10) - 1) == 0) ||
|
||||
(strncmp(s.httpheaderline, http_11,
|
||||
sizeof(http_11) - 1) == 0)) {
|
||||
sizeof(http_11) - 1) == 0))
|
||||
{
|
||||
cptr = &(s.httpheaderline[9]);
|
||||
s.httpflag = HTTPFLAG_NONE;
|
||||
if(strncmp(cptr, http_200, sizeof(http_200) - 1) == 0) {
|
||||
if (strncmp(cptr, http_200, sizeof(http_200) - 1) == 0)
|
||||
{
|
||||
/* 200 OK */
|
||||
s.httpflag = HTTPFLAG_OK;
|
||||
} else if(strncmp(cptr, http_301, sizeof(http_301) - 1) == 0 ||
|
||||
strncmp(cptr, http_302, sizeof(http_302) - 1) == 0) {
|
||||
}
|
||||
else if (strncmp(cptr, http_301, sizeof(http_301) - 1) == 0 ||
|
||||
strncmp(cptr, http_302, sizeof(http_302) - 1) == 0)
|
||||
{
|
||||
/* 301 Moved permanently or 302 Found. Location: header line
|
||||
will contain thw new location. */
|
||||
s.httpflag = HTTPFLAG_MOVED;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
s.httpheaderline[s.httpheaderlineptr - 1] = 0;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
uip_abort();
|
||||
webclient_aborted();
|
||||
return 0;
|
||||
|
@ -259,7 +274,9 @@ parse_statusline(u16_t len)
|
|||
s.httpheaderlineptr = 0;
|
||||
s.state = WEBCLIENT_STATE_HEADERS;
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
++s.httpheaderlineptr;
|
||||
}
|
||||
}
|
||||
|
@ -271,13 +288,16 @@ casecmp(char *str1, const char *str2, char len)
|
|||
{
|
||||
static char c;
|
||||
|
||||
while(len > 0) {
|
||||
while (len > 0)
|
||||
{
|
||||
c = *str1;
|
||||
/* Force lower-case characters. */
|
||||
if(c & 0x40) {
|
||||
if (c & 0x40)
|
||||
{
|
||||
c |= 0x20;
|
||||
}
|
||||
if(*str2 != c) {
|
||||
if (*str2 != c)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
++str1;
|
||||
|
@ -293,14 +313,17 @@ parse_headers(u16_t len)
|
|||
char *cptr;
|
||||
static unsigned char i;
|
||||
|
||||
while(len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline)) {
|
||||
while (len > 0 && s.httpheaderlineptr < sizeof(s.httpheaderline))
|
||||
{
|
||||
s.httpheaderline[s.httpheaderlineptr] = *(char *)uip_appdata;
|
||||
++((char *)uip_appdata);
|
||||
--len;
|
||||
if(s.httpheaderline[s.httpheaderlineptr] == ISO_nl) {
|
||||
if (s.httpheaderline[s.httpheaderlineptr] == ISO_nl)
|
||||
{
|
||||
/* We have an entire HTTP header line in s.httpheaderline, so
|
||||
we parse it. */
|
||||
if(s.httpheaderline[0] == ISO_cr) {
|
||||
if (s.httpheaderline[0] == ISO_cr)
|
||||
{
|
||||
/* This was the last header line (i.e., and empty "\r\n"), so
|
||||
we are done with the headers and proceed with the actual
|
||||
data. */
|
||||
|
@ -310,27 +333,34 @@ parse_headers(u16_t len)
|
|||
|
||||
s.httpheaderline[s.httpheaderlineptr - 1] = 0;
|
||||
/* Check for specific HTTP header fields. */
|
||||
if(casecmp(s.httpheaderline, http_content_type,
|
||||
sizeof(http_content_type) - 1) == 0) {
|
||||
if (casecmp(s.httpheaderline, http_content_type,
|
||||
sizeof(http_content_type) - 1) == 0)
|
||||
{
|
||||
/* Found Content-type field. */
|
||||
cptr = strchr(s.httpheaderline, ';');
|
||||
if(cptr != NULL) {
|
||||
if (cptr != NULL)
|
||||
{
|
||||
*cptr = 0;
|
||||
}
|
||||
strncpy(s.mimetype, s.httpheaderline +
|
||||
sizeof(http_content_type) - 1, sizeof(s.mimetype));
|
||||
} else if(casecmp(s.httpheaderline, http_location,
|
||||
sizeof(http_location) - 1) == 0) {
|
||||
}
|
||||
else if (casecmp(s.httpheaderline, http_location,
|
||||
sizeof(http_location) - 1) == 0)
|
||||
{
|
||||
cptr = s.httpheaderline +
|
||||
sizeof(http_location) - 1;
|
||||
|
||||
if(strncmp(cptr, http_http, 7) == 0) {
|
||||
if (strncmp(cptr, http_http, 7) == 0)
|
||||
{
|
||||
cptr += 7;
|
||||
for(i = 0; i < s.httpheaderlineptr - 7; ++i) {
|
||||
if(*cptr == 0 ||
|
||||
for (i = 0; i < s.httpheaderlineptr - 7; ++i)
|
||||
{
|
||||
if (*cptr == 0 ||
|
||||
*cptr == '/' ||
|
||||
*cptr == ' ' ||
|
||||
*cptr == ':') {
|
||||
*cptr == ':')
|
||||
{
|
||||
s.host[i] = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -346,7 +376,9 @@ parse_headers(u16_t len)
|
|||
/* We're done parsing, so we reset the pointer and start the
|
||||
next line. */
|
||||
s.httpheaderlineptr = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
++s.httpheaderlineptr;
|
||||
}
|
||||
}
|
||||
|
@ -360,16 +392,19 @@ newdata(void)
|
|||
|
||||
len = uip_datalen();
|
||||
|
||||
if(s.state == WEBCLIENT_STATE_STATUSLINE) {
|
||||
if (s.state == WEBCLIENT_STATE_STATUSLINE)
|
||||
{
|
||||
len = parse_statusline(len);
|
||||
}
|
||||
|
||||
if(s.state == WEBCLIENT_STATE_HEADERS && len > 0) {
|
||||
if (s.state == WEBCLIENT_STATE_HEADERS && len > 0)
|
||||
{
|
||||
len = parse_headers(len);
|
||||
}
|
||||
|
||||
if(len > 0 && s.state == WEBCLIENT_STATE_DATA &&
|
||||
s.httpflag != HTTPFLAG_MOVED) {
|
||||
if (len > 0 && s.state == WEBCLIENT_STATE_DATA &&
|
||||
s.httpflag != HTTPFLAG_MOVED)
|
||||
{
|
||||
webclient_datahandler((char *)uip_appdata, len);
|
||||
}
|
||||
}
|
||||
|
@ -377,7 +412,8 @@ newdata(void)
|
|||
void
|
||||
webclient_appcall(void)
|
||||
{
|
||||
if(uip_connected()) {
|
||||
if (uip_connected())
|
||||
{
|
||||
s.timer = 0;
|
||||
s.state = WEBCLIENT_STATE_STATUSLINE;
|
||||
senddata();
|
||||
|
@ -385,35 +421,44 @@ webclient_appcall(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if(s.state == WEBCLIENT_STATE_CLOSE) {
|
||||
if (s.state == WEBCLIENT_STATE_CLOSE)
|
||||
{
|
||||
webclient_closed();
|
||||
uip_abort();
|
||||
return;
|
||||
}
|
||||
|
||||
if(uip_aborted()) {
|
||||
if (uip_aborted())
|
||||
{
|
||||
webclient_aborted();
|
||||
}
|
||||
if(uip_timedout()) {
|
||||
if (uip_timedout())
|
||||
{
|
||||
webclient_timedout();
|
||||
}
|
||||
|
||||
|
||||
if(uip_acked()) {
|
||||
if (uip_acked())
|
||||
{
|
||||
s.timer = 0;
|
||||
acked();
|
||||
}
|
||||
if(uip_newdata()) {
|
||||
if (uip_newdata())
|
||||
{
|
||||
s.timer = 0;
|
||||
newdata();
|
||||
}
|
||||
if(uip_rexmit() ||
|
||||
if (uip_rexmit() ||
|
||||
uip_newdata() ||
|
||||
uip_acked()) {
|
||||
uip_acked())
|
||||
{
|
||||
senddata();
|
||||
} else if(uip_poll()) {
|
||||
}
|
||||
else if (uip_poll())
|
||||
{
|
||||
++s.timer;
|
||||
if(s.timer == WEBCLIENT_TIMEOUT) {
|
||||
if (s.timer == WEBCLIENT_TIMEOUT)
|
||||
{
|
||||
webclient_timedout();
|
||||
uip_abort();
|
||||
return;
|
||||
|
@ -421,12 +466,17 @@ webclient_appcall(void)
|
|||
/* senddata();*/
|
||||
}
|
||||
|
||||
if(uip_closed()) {
|
||||
if(s.httpflag != HTTPFLAG_MOVED) {
|
||||
if (uip_closed())
|
||||
{
|
||||
if (s.httpflag != HTTPFLAG_MOVED)
|
||||
{
|
||||
/* Send NULL data to signal EOF. */
|
||||
webclient_datahandler(NULL, 0);
|
||||
} else {
|
||||
if(resolv_lookup(s.host) == NULL) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (resolv_lookup(s.host) == NULL)
|
||||
{
|
||||
resolv_query(s.host);
|
||||
}
|
||||
webclient_get(s.host, s.port, s.file);
|
||||
|
|
|
@ -52,7 +52,8 @@
|
|||
|
||||
#define WEBCLIENT_CONF_MAX_URLLEN 100
|
||||
|
||||
struct webclient_state {
|
||||
struct webclient_state
|
||||
{
|
||||
u8_t timer;
|
||||
u8_t state;
|
||||
u8_t httpflag;
|
||||
|
|
|
@ -1,102 +1,102 @@
|
|||
const char http_http[8] =
|
||||
/* "http://" */
|
||||
/* "http://" */
|
||||
{0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, };
|
||||
const char http_200[5] =
|
||||
/* "200 " */
|
||||
/* "200 " */
|
||||
{0x32, 0x30, 0x30, 0x20, };
|
||||
const char http_301[5] =
|
||||
/* "301 " */
|
||||
/* "301 " */
|
||||
{0x33, 0x30, 0x31, 0x20, };
|
||||
const char http_302[5] =
|
||||
/* "302 " */
|
||||
/* "302 " */
|
||||
{0x33, 0x30, 0x32, 0x20, };
|
||||
const char http_get[5] =
|
||||
/* "GET " */
|
||||
/* "GET " */
|
||||
{0x47, 0x45, 0x54, 0x20, };
|
||||
const char http_10[9] =
|
||||
/* "HTTP/1.0" */
|
||||
/* "HTTP/1.0" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, };
|
||||
const char http_11[9] =
|
||||
/* "HTTP/1.1" */
|
||||
/* "HTTP/1.1" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, };
|
||||
const char http_content_type[15] =
|
||||
/* "content-type: " */
|
||||
/* "content-type: " */
|
||||
{0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, };
|
||||
const char http_texthtml[10] =
|
||||
/* "text/html" */
|
||||
/* "text/html" */
|
||||
{0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_location[11] =
|
||||
/* "location: " */
|
||||
/* "location: " */
|
||||
{0x6c, 0x6f, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, };
|
||||
const char http_host[7] =
|
||||
/* "host: " */
|
||||
/* "host: " */
|
||||
{0x68, 0x6f, 0x73, 0x74, 0x3a, 0x20, };
|
||||
const char http_crnl[3] =
|
||||
/* "\r\n" */
|
||||
/* "\r\n" */
|
||||
{0xd, 0xa, };
|
||||
const char http_index_html[12] =
|
||||
/* "/index.html" */
|
||||
/* "/index.html" */
|
||||
{0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_404_html[10] =
|
||||
/* "/404.html" */
|
||||
/* "/404.html" */
|
||||
{0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_referer[9] =
|
||||
/* "Referer:" */
|
||||
/* "Referer:" */
|
||||
{0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x72, 0x3a, };
|
||||
const char http_header_200[84] =
|
||||
/* "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
|
||||
/* "HTTP/1.0 200 OK\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
|
||||
const char http_header_404[91] =
|
||||
/* "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
|
||||
/* "HTTP/1.0 404 Not found\r\nServer: uIP/1.0 http://www.sics.se/~adam/uip/\r\nConnection: close\r\n" */
|
||||
{0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x34, 0x30, 0x34, 0x20, 0x4e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0xd, 0xa, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x3a, 0x20, 0x75, 0x49, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x73, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x2f, 0x7e, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x75, 0x69, 0x70, 0x2f, 0xd, 0xa, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, };
|
||||
const char http_content_type_plain[29] =
|
||||
/* "Content-type: text/plain\r\n\r\n" */
|
||||
/* "Content-type: text/plain\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_html[28] =
|
||||
/* "Content-type: text/html\r\n\r\n" */
|
||||
/* "Content-type: text/html\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_css [27] =
|
||||
/* "Content-type: text/css\r\n\r\n" */
|
||||
/* "Content-type: text/css\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x63, 0x73, 0x73, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_text[28] =
|
||||
/* "Content-type: text/text\r\n\r\n" */
|
||||
/* "Content-type: text/text\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x74, 0x65, 0x78, 0x74, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_png [28] =
|
||||
/* "Content-type: image/png\r\n\r\n" */
|
||||
/* "Content-type: image/png\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_gif [28] =
|
||||
/* "Content-type: image/gif\r\n\r\n" */
|
||||
/* "Content-type: image/gif\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x67, 0x69, 0x66, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_jpg [29] =
|
||||
/* "Content-type: image/jpeg\r\n\r\n" */
|
||||
/* "Content-type: image/jpeg\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x6a, 0x70, 0x65, 0x67, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_content_type_binary[43] =
|
||||
/* "Content-type: application/octet-stream\r\n\r\n" */
|
||||
/* "Content-type: application/octet-stream\r\n\r\n" */
|
||||
{0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, };
|
||||
const char http_html[6] =
|
||||
/* ".html" */
|
||||
/* ".html" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_shtml[7] =
|
||||
/* ".shtml" */
|
||||
/* ".shtml" */
|
||||
{0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, };
|
||||
const char http_htm[5] =
|
||||
/* ".htm" */
|
||||
/* ".htm" */
|
||||
{0x2e, 0x68, 0x74, 0x6d, };
|
||||
const char http_css[5] =
|
||||
/* ".css" */
|
||||
/* ".css" */
|
||||
{0x2e, 0x63, 0x73, 0x73, };
|
||||
const char http_png[5] =
|
||||
/* ".png" */
|
||||
/* ".png" */
|
||||
{0x2e, 0x70, 0x6e, 0x67, };
|
||||
const char http_gif[5] =
|
||||
/* ".gif" */
|
||||
/* ".gif" */
|
||||
{0x2e, 0x67, 0x69, 0x66, };
|
||||
const char http_jpg[5] =
|
||||
/* ".jpg" */
|
||||
/* ".jpg" */
|
||||
{0x2e, 0x6a, 0x70, 0x67, };
|
||||
const char http_text[5] =
|
||||
/* ".txt" */
|
||||
/* ".txt" */
|
||||
{0x2e, 0x74, 0x78, 0x74, };
|
||||
const char http_txt[5] =
|
||||
/* ".txt" */
|
||||
/* ".txt" */
|
||||
{0x2e, 0x74, 0x78, 0x74, };
|
||||
|
|
|
@ -74,8 +74,10 @@ httpd_cgi(char *name)
|
|||
const struct httpd_cgi_call **f;
|
||||
|
||||
/* Find the matching name in the table, return the function. */
|
||||
for(f = calls; *f != NULL; ++f) {
|
||||
if(strncmp((*f)->name, name, strlen((*f)->name)) == 0) {
|
||||
for (f = calls; *f != NULL; ++f)
|
||||
{
|
||||
if (strncmp((*f)->name, name, strlen((*f)->name)) == 0)
|
||||
{
|
||||
return (*f)->function;
|
||||
}
|
||||
}
|
||||
|
@ -102,31 +104,48 @@ PT_THREAD(file_stats(struct httpd_state *s, char *ptr))
|
|||
static const char closed[] = /* "CLOSED",*/
|
||||
{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
|
||||
static const char syn_rcvd[] = /* "SYN-RCVD",*/
|
||||
{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56,
|
||||
0x44, 0};
|
||||
{
|
||||
0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56,
|
||||
0x44, 0
|
||||
};
|
||||
static const char syn_sent[] = /* "SYN-SENT",*/
|
||||
{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e,
|
||||
0x54, 0};
|
||||
{
|
||||
0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e,
|
||||
0x54, 0
|
||||
};
|
||||
static const char established[] = /* "ESTABLISHED",*/
|
||||
{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48,
|
||||
0x45, 0x44, 0};
|
||||
{
|
||||
0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48,
|
||||
0x45, 0x44, 0
|
||||
};
|
||||
static const char fin_wait_1[] = /* "FIN-WAIT-1",*/
|
||||
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
|
||||
0x54, 0x2d, 0x31, 0};
|
||||
{
|
||||
0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
|
||||
0x54, 0x2d, 0x31, 0
|
||||
};
|
||||
static const char fin_wait_2[] = /* "FIN-WAIT-2",*/
|
||||
{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
|
||||
0x54, 0x2d, 0x32, 0};
|
||||
{
|
||||
0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49,
|
||||
0x54, 0x2d, 0x32, 0
|
||||
};
|
||||
static const char closing[] = /* "CLOSING",*/
|
||||
{0x43, 0x4c, 0x4f, 0x53, 0x49,
|
||||
0x4e, 0x47, 0};
|
||||
{
|
||||
0x43, 0x4c, 0x4f, 0x53, 0x49,
|
||||
0x4e, 0x47, 0
|
||||
};
|
||||
static const char time_wait[] = /* "TIME-WAIT,"*/
|
||||
{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41,
|
||||
0x49, 0x54, 0};
|
||||
{
|
||||
0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41,
|
||||
0x49, 0x54, 0
|
||||
};
|
||||
static const char last_ack[] = /* "LAST-ACK"*/
|
||||
{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43,
|
||||
0x4b, 0};
|
||||
{
|
||||
0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43,
|
||||
0x4b, 0
|
||||
};
|
||||
|
||||
static const char *states[] = {
|
||||
static const char *states[] =
|
||||
{
|
||||
closed,
|
||||
syn_rcvd,
|
||||
syn_sent,
|
||||
|
@ -135,7 +154,8 @@ static const char *states[] = {
|
|||
fin_wait_2,
|
||||
closing,
|
||||
time_wait,
|
||||
last_ack};
|
||||
last_ack
|
||||
};
|
||||
|
||||
|
||||
static unsigned short
|
||||
|
@ -166,8 +186,10 @@ PT_THREAD(tcp_stats(struct httpd_state *s, char *ptr))
|
|||
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
for(s->count = 0; s->count < UIP_CONNS; ++s->count) {
|
||||
if((uip_conns[s->count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED) {
|
||||
for (s->count = 0; s->count < UIP_CONNS; ++s->count)
|
||||
{
|
||||
if ((uip_conns[s->count].tcpstateflags & UIP_TS_MASK) != UIP_CLOSED)
|
||||
{
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_tcp_stats, s);
|
||||
}
|
||||
}
|
||||
|
@ -190,8 +212,9 @@ PT_THREAD(net_stats(struct httpd_state *s, char *ptr))
|
|||
|
||||
#if UIP_STATISTICS
|
||||
|
||||
for(s->count = 0; s->count < sizeof(uip_stat) / sizeof(uip_stats_t);
|
||||
++s->count) {
|
||||
for (s->count = 0; s->count < sizeof(uip_stat) / sizeof(uip_stats_t);
|
||||
++s->count)
|
||||
{
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_net_stats, s);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,8 @@ typedef PT_THREAD((* httpd_cgifunction)(struct httpd_state *, char *));
|
|||
|
||||
httpd_cgifunction httpd_cgi(char *name);
|
||||
|
||||
struct httpd_cgi_call {
|
||||
struct httpd_cgi_call
|
||||
{
|
||||
const char *name;
|
||||
const httpd_cgifunction function;
|
||||
};
|
||||
|
|
|
@ -53,15 +53,17 @@ httpd_fs_strcmp(const char *str1, const char *str2)
|
|||
{
|
||||
u8_t i;
|
||||
i = 0;
|
||||
loop:
|
||||
loop:
|
||||
|
||||
if(str2[i] == 0 ||
|
||||
if (str2[i] == 0 ||
|
||||
str1[i] == '\r' ||
|
||||
str1[i] == '\n') {
|
||||
str1[i] == '\n')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(str1[i] != str2[i]) {
|
||||
if (str1[i] != str2[i])
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -78,11 +80,13 @@ httpd_fs_open(const char *name, struct httpd_fs_file *file)
|
|||
#endif /* HTTPD_FS_STATISTICS */
|
||||
struct httpd_fsdata_file_noconst *f;
|
||||
|
||||
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
|
||||
for (f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
|
||||
f != NULL;
|
||||
f = (struct httpd_fsdata_file_noconst *)f->next) {
|
||||
f = (struct httpd_fsdata_file_noconst *)f->next)
|
||||
{
|
||||
|
||||
if(httpd_fs_strcmp(name, f->name) == 0) {
|
||||
if (httpd_fs_strcmp(name, f->name) == 0)
|
||||
{
|
||||
file->data = f->data;
|
||||
file->len = f->len;
|
||||
#if HTTPD_FS_STATISTICS
|
||||
|
@ -103,7 +107,8 @@ httpd_fs_init(void)
|
|||
{
|
||||
#if HTTPD_FS_STATISTICS
|
||||
u16_t i;
|
||||
for(i = 0; i < HTTPD_FS_NUMFILES; i++) {
|
||||
for (i = 0; i < HTTPD_FS_NUMFILES; i++)
|
||||
{
|
||||
count[i] = 0;
|
||||
}
|
||||
#endif /* HTTPD_FS_STATISTICS */
|
||||
|
@ -117,11 +122,13 @@ u16_t httpd_fs_count
|
|||
u16_t i;
|
||||
|
||||
i = 0;
|
||||
for(f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
|
||||
for (f = (struct httpd_fsdata_file_noconst *)HTTPD_FS_ROOT;
|
||||
f != NULL;
|
||||
f = (struct httpd_fsdata_file_noconst *)f->next) {
|
||||
f = (struct httpd_fsdata_file_noconst *)f->next)
|
||||
{
|
||||
|
||||
if(httpd_fs_strcmp(name, f->name) == 0) {
|
||||
if (httpd_fs_strcmp(name, f->name) == 0)
|
||||
{
|
||||
return count[i];
|
||||
}
|
||||
++i;
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
|
||||
#define HTTPD_FS_STATISTICS 1
|
||||
|
||||
struct httpd_fs_file {
|
||||
struct httpd_fs_file
|
||||
{
|
||||
char *data;
|
||||
int len;
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
static const unsigned char data_processes_shtml[] = {
|
||||
static const unsigned char data_processes_shtml[] =
|
||||
{
|
||||
/* /processes.shtml */
|
||||
0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
|
@ -21,9 +22,11 @@ static const unsigned char data_processes_shtml[] = {
|
|||
0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 0x25,
|
||||
0x21, 0x20, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65,
|
||||
0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66, 0x6f, 0x6f,
|
||||
0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0};
|
||||
0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0
|
||||
};
|
||||
|
||||
static const unsigned char data_404_html[] = {
|
||||
static const unsigned char data_404_html[] =
|
||||
{
|
||||
/* /404.html */
|
||||
0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0xa, 0x20, 0x20, 0x3c,
|
||||
|
@ -42,9 +45,11 @@ static const unsigned char data_404_html[] = {
|
|||
0x20, 0x20, 0x20, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74, 0x65,
|
||||
0x72, 0x3e, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64,
|
||||
0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e,
|
||||
0};
|
||||
0
|
||||
};
|
||||
|
||||
static const unsigned char data_files_shtml[] = {
|
||||
static const unsigned char data_files_shtml[] =
|
||||
{
|
||||
/* /files.shtml */
|
||||
0x2f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
|
@ -172,15 +177,19 @@ static const unsigned char data_files_shtml[] = {
|
|||
0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f, 0x63, 0x65,
|
||||
0x6e, 0x74, 0x65, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x3a, 0x20,
|
||||
0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74,
|
||||
0x6d, 0x6c, 0xa, 0};
|
||||
0x6d, 0x6c, 0xa, 0
|
||||
};
|
||||
|
||||
static const unsigned char data_footer_html[] = {
|
||||
static const unsigned char data_footer_html[] =
|
||||
{
|
||||
/* /footer.html */
|
||||
0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x20, 0x20, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0xa,
|
||||
0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0};
|
||||
0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0
|
||||
};
|
||||
|
||||
static const unsigned char data_header_html[] = {
|
||||
static const unsigned char data_header_html[] =
|
||||
{
|
||||
/* /header.html */
|
||||
0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20,
|
||||
|
@ -245,9 +254,11 @@ static const unsigned char data_header_html[] = {
|
|||
0x2f, 0x64, 0x69, 0x76, 0x3e, 0xa, 0x20, 0x20, 0xa, 0x20,
|
||||
0x20, 0x3c, 0x64, 0x69, 0x76, 0x20, 0x63, 0x6c, 0x61, 0x73,
|
||||
0x73, 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
|
||||
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0};
|
||||
0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x3e, 0xa, 0
|
||||
};
|
||||
|
||||
static const unsigned char data_index_html[] = {
|
||||
static const unsigned char data_index_html[] =
|
||||
{
|
||||
/* /index.html */
|
||||
0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x3c, 0x21, 0x44, 0x4f, 0x43, 0x54, 0x59, 0x50, 0x45, 0x20,
|
||||
|
@ -337,9 +348,11 @@ static const unsigned char data_index_html[] = {
|
|||
0x73, 0x74, 0x69, 0x63, 0x73, 0x2e, 0xa, 0x20, 0x20, 0x3c,
|
||||
0x2f, 0x70, 0x3e, 0xa, 0xa, 0x20, 0x20, 0x3c, 0x2f, 0x62,
|
||||
0x6f, 0x64, 0x79, 0x3e, 0xa, 0x3c, 0x2f, 0x68, 0x74, 0x6d,
|
||||
0x6c, 0x3e, 0xa, 0};
|
||||
0x6c, 0x3e, 0xa, 0
|
||||
};
|
||||
|
||||
static const unsigned char data_style_css[] = {
|
||||
static const unsigned char data_style_css[] =
|
||||
{
|
||||
/* /style.css */
|
||||
0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x2e, 0x63, 0x73, 0x73, 0,
|
||||
0x68, 0x31, 0x20, 0xa, 0x7b, 0xa, 0x20, 0x20, 0x74, 0x65,
|
||||
|
@ -443,9 +456,11 @@ static const unsigned char data_style_css[] = {
|
|||
0x70, 0x2e, 0x72, 0x69, 0x67, 0x68, 0x74, 0xa, 0x7b, 0xa,
|
||||
0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x61, 0x6c, 0x69,
|
||||
0x67, 0x6e, 0x3a, 0x72, 0x69, 0x67, 0x68, 0x74, 0x3b, 0x20,
|
||||
0xa, 0x7d, 0xa, 0xa, 0};
|
||||
0xa, 0x7d, 0xa, 0xa, 0
|
||||
};
|
||||
|
||||
static const unsigned char data_tcp_shtml[] = {
|
||||
static const unsigned char data_tcp_shtml[] =
|
||||
{
|
||||
/* /tcp.shtml */
|
||||
0x2f, 0x74, 0x63, 0x70, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
|
@ -469,9 +484,11 @@ static const unsigned char data_tcp_shtml[] = {
|
|||
0x70, 0x2d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66,
|
||||
0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c,
|
||||
0};
|
||||
0
|
||||
};
|
||||
|
||||
static const unsigned char data_fade_png[] = {
|
||||
static const unsigned char data_fade_png[] =
|
||||
{
|
||||
/* /fade.png */
|
||||
0x2f, 0x66, 0x61, 0x64, 0x65, 0x2e, 0x70, 0x6e, 0x67, 0,
|
||||
0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 00, 00,
|
||||
|
@ -493,9 +510,11 @@ static const unsigned char data_fade_png[] = {
|
|||
0x1, 0xf8, 0x29, 0x58, 0xc8, 0xbf, 0x48, 0xc4, 0x81, 0x74,
|
||||
0xb, 0xa3, 0xf, 0x7c, 0xdb, 0x4, 0xe8, 0x40, 0x5, 0xdf,
|
||||
0xa1, 0xf3, 0xfc, 0x73, 00, 00, 00, 00, 0x49, 0x45,
|
||||
0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, 0};
|
||||
0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, 0
|
||||
};
|
||||
|
||||
static const unsigned char data_stats_shtml[] = {
|
||||
static const unsigned char data_stats_shtml[] =
|
||||
{
|
||||
/* /stats.shtml */
|
||||
0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x73, 0x68, 0x74, 0x6d, 0x6c, 0,
|
||||
0x25, 0x21, 0x3a, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65,
|
||||
|
@ -580,7 +599,8 @@ static const unsigned char data_stats_shtml[] = {
|
|||
0x6c, 0x65, 0x3e, 0xa, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 0x74,
|
||||
0x65, 0x72, 0x3e, 0xa, 0x25, 0x21, 0x3a, 0x20, 0x2f, 0x66,
|
||||
0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c,
|
||||
0xa, 0};
|
||||
0xa, 0
|
||||
};
|
||||
|
||||
const struct httpd_fsdata_file file_processes_shtml[] = {{NULL, data_processes_shtml, data_processes_shtml + 17, sizeof(data_processes_shtml) - 17}};
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
|
||||
#include "uip.h"
|
||||
|
||||
struct httpd_fsdata_file {
|
||||
struct httpd_fsdata_file
|
||||
{
|
||||
const struct httpd_fsdata_file *next;
|
||||
const char *name;
|
||||
const char *data;
|
||||
|
@ -49,7 +50,8 @@ struct httpd_fsdata_file {
|
|||
#endif /* HTTPD_FS_STATISTICS */
|
||||
};
|
||||
|
||||
struct httpd_fsdata_file_noconst {
|
||||
struct httpd_fsdata_file_noconst
|
||||
{
|
||||
struct httpd_fsdata_file *next;
|
||||
char *name;
|
||||
char *data;
|
||||
|
|
|
@ -81,9 +81,12 @@ generate_part_of_file(void *state)
|
|||
{
|
||||
struct httpd_state *s = (struct httpd_state *)state;
|
||||
|
||||
if(s->file.len > uip_mss()) {
|
||||
if (s->file.len > uip_mss())
|
||||
{
|
||||
s->len = uip_mss();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
s->len = s->file.len;
|
||||
}
|
||||
memcpy(uip_appdata, s->file.data, s->len);
|
||||
|
@ -96,11 +99,13 @@ PT_THREAD(send_file(struct httpd_state *s))
|
|||
{
|
||||
PSOCK_BEGIN(&s->sout);
|
||||
|
||||
do {
|
||||
do
|
||||
{
|
||||
PSOCK_GENERATOR_SEND(&s->sout, generate_part_of_file, s);
|
||||
s->file.len -= s->len;
|
||||
s->file.data += s->len;
|
||||
} while(s->file.len > 0);
|
||||
}
|
||||
while (s->file.len > 0);
|
||||
|
||||
PSOCK_END(&s->sout);
|
||||
}
|
||||
|
@ -132,17 +137,22 @@ PT_THREAD(handle_script(struct httpd_state *s))
|
|||
PT_BEGIN(&s->scriptpt);
|
||||
|
||||
|
||||
while(s->file.len > 0) {
|
||||
while (s->file.len > 0)
|
||||
{
|
||||
|
||||
/* Check if we should start executing a script. */
|
||||
if(*s->file.data == ISO_percent &&
|
||||
*(s->file.data + 1) == ISO_bang) {
|
||||
if (*s->file.data == ISO_percent &&
|
||||
*(s->file.data + 1) == ISO_bang)
|
||||
{
|
||||
s->scriptptr = s->file.data + 3;
|
||||
s->scriptlen = s->file.len - 3;
|
||||
if(*(s->scriptptr - 1) == ISO_colon) {
|
||||
if (*(s->scriptptr - 1) == ISO_colon)
|
||||
{
|
||||
httpd_fs_open(s->scriptptr + 1, &s->file);
|
||||
PT_WAIT_THREAD(&s->scriptpt, send_file(s));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
PT_WAIT_THREAD(&s->scriptpt,
|
||||
httpd_cgi(s->scriptptr)(s, s->scriptptr));
|
||||
}
|
||||
|
@ -152,25 +162,35 @@ PT_THREAD(handle_script(struct httpd_state *s))
|
|||
sending the rest of the file. */
|
||||
s->file.data = s->scriptptr;
|
||||
s->file.len = s->scriptlen;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
/* See if we find the start of script marker in the block of HTML
|
||||
to be sent. */
|
||||
|
||||
if(s->file.len > uip_mss()) {
|
||||
if (s->file.len > uip_mss())
|
||||
{
|
||||
s->len = uip_mss();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
s->len = s->file.len;
|
||||
}
|
||||
|
||||
if(*s->file.data == ISO_percent) {
|
||||
if (*s->file.data == ISO_percent)
|
||||
{
|
||||
ptr = strchr(s->file.data + 1, ISO_percent);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = strchr(s->file.data, ISO_percent);
|
||||
}
|
||||
if(ptr != NULL &&
|
||||
ptr != s->file.data) {
|
||||
if (ptr != NULL &&
|
||||
ptr != s->file.data)
|
||||
{
|
||||
s->len = (int)(ptr - s->file.data);
|
||||
if(s->len >= uip_mss()) {
|
||||
if (s->len >= uip_mss())
|
||||
{
|
||||
s->len = uip_mss();
|
||||
}
|
||||
}
|
||||
|
@ -194,20 +214,33 @@ PT_THREAD(send_headers(struct httpd_state *s, const char *statushdr))
|
|||
PSOCK_SEND_STR(&s->sout, statushdr);
|
||||
|
||||
ptr = strrchr(s->filename, ISO_period);
|
||||
if(ptr == NULL) {
|
||||
if (ptr == NULL)
|
||||
{
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_binary);
|
||||
} else if(strncmp(http_html, ptr, 5) == 0 ||
|
||||
strncmp(http_shtml, ptr, 6) == 0) {
|
||||
}
|
||||
else if (strncmp(http_html, ptr, 5) == 0 ||
|
||||
strncmp(http_shtml, ptr, 6) == 0)
|
||||
{
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_html);
|
||||
} else if(strncmp(http_css, ptr, 4) == 0) {
|
||||
}
|
||||
else if (strncmp(http_css, ptr, 4) == 0)
|
||||
{
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_css);
|
||||
} else if(strncmp(http_png, ptr, 4) == 0) {
|
||||
}
|
||||
else if (strncmp(http_png, ptr, 4) == 0)
|
||||
{
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_png);
|
||||
} else if(strncmp(http_gif, ptr, 4) == 0) {
|
||||
}
|
||||
else if (strncmp(http_gif, ptr, 4) == 0)
|
||||
{
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_gif);
|
||||
} else if(strncmp(http_jpg, ptr, 4) == 0) {
|
||||
}
|
||||
else if (strncmp(http_jpg, ptr, 4) == 0)
|
||||
{
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_jpg);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
PSOCK_SEND_STR(&s->sout, http_content_type_plain);
|
||||
}
|
||||
PSOCK_END(&s->sout);
|
||||
|
@ -220,7 +253,8 @@ PT_THREAD(handle_output(struct httpd_state *s))
|
|||
|
||||
PT_BEGIN(&s->outputpt);
|
||||
|
||||
if(!httpd_fs_open(s->filename, &s->file)) {
|
||||
if (!httpd_fs_open(s->filename, &s->file))
|
||||
{
|
||||
httpd_fs_open(http_404_html, &s->file);
|
||||
strcpy(s->filename, http_404_html);
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
|
@ -228,15 +262,20 @@ PT_THREAD(handle_output(struct httpd_state *s))
|
|||
http_header_404));
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_file(s));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_headers(s,
|
||||
http_header_200));
|
||||
ptr = strchr(s->filename, ISO_period);
|
||||
if(ptr != NULL && strncmp(ptr, http_shtml, 6) == 0) {
|
||||
if (ptr != NULL && strncmp(ptr, http_shtml, 6) == 0)
|
||||
{
|
||||
PT_INIT(&s->scriptpt);
|
||||
PT_WAIT_THREAD(&s->outputpt, handle_script(s));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
PT_WAIT_THREAD(&s->outputpt,
|
||||
send_file(s));
|
||||
}
|
||||
|
@ -253,18 +292,23 @@ PT_THREAD(handle_input(struct httpd_state *s))
|
|||
PSOCK_READTO(&s->sin, ISO_space);
|
||||
|
||||
|
||||
if(strncmp(s->inputbuf, http_get, 4) != 0) {
|
||||
if (strncmp(s->inputbuf, http_get, 4) != 0)
|
||||
{
|
||||
PSOCK_CLOSE_EXIT(&s->sin);
|
||||
}
|
||||
PSOCK_READTO(&s->sin, ISO_space);
|
||||
|
||||
if(s->inputbuf[0] != ISO_slash) {
|
||||
if (s->inputbuf[0] != ISO_slash)
|
||||
{
|
||||
PSOCK_CLOSE_EXIT(&s->sin);
|
||||
}
|
||||
|
||||
if(s->inputbuf[1] == ISO_space) {
|
||||
if (s->inputbuf[1] == ISO_space)
|
||||
{
|
||||
strncpy(s->filename, http_index_html, sizeof(s->filename));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 1] = 0;
|
||||
strncpy(s->filename, &s->inputbuf[0], sizeof(s->filename));
|
||||
}
|
||||
|
@ -273,10 +317,12 @@ PT_THREAD(handle_input(struct httpd_state *s))
|
|||
|
||||
s->state = STATE_OUTPUT;
|
||||
|
||||
while(1) {
|
||||
while (1)
|
||||
{
|
||||
PSOCK_READTO(&s->sin, ISO_nl);
|
||||
|
||||
if(strncmp(s->inputbuf, http_referer, 8) == 0) {
|
||||
if (strncmp(s->inputbuf, http_referer, 8) == 0)
|
||||
{
|
||||
s->inputbuf[PSOCK_DATALEN(&s->sin) - 2] = 0;
|
||||
/* httpd_log(&s->inputbuf[9]);*/
|
||||
}
|
||||
|
@ -289,7 +335,8 @@ static void
|
|||
handle_connection(struct httpd_state *s)
|
||||
{
|
||||
handle_input(s);
|
||||
if(s->state == STATE_OUTPUT) {
|
||||
if (s->state == STATE_OUTPUT)
|
||||
{
|
||||
handle_output(s);
|
||||
}
|
||||
}
|
||||
|
@ -299,8 +346,11 @@ httpd_appcall(void)
|
|||
{
|
||||
struct httpd_state *s = (struct httpd_state *)&(uip_conn->appstate);
|
||||
|
||||
if(uip_closed() || uip_aborted() || uip_timedout()) {
|
||||
} else if(uip_connected()) {
|
||||
if (uip_closed() || uip_aborted() || uip_timedout())
|
||||
{
|
||||
}
|
||||
else if (uip_connected())
|
||||
{
|
||||
PSOCK_INIT(&s->sin, s->inputbuf, sizeof(s->inputbuf) - 1);
|
||||
PSOCK_INIT(&s->sout, s->inputbuf, sizeof(s->inputbuf) - 1);
|
||||
PT_INIT(&s->outputpt);
|
||||
|
@ -308,17 +358,25 @@ httpd_appcall(void)
|
|||
/* timer_set(&s->timer, CLOCK_SECOND * 100);*/
|
||||
s->timer = 0;
|
||||
handle_connection(s);
|
||||
} else if(s != NULL) {
|
||||
if(uip_poll()) {
|
||||
}
|
||||
else if (s != NULL)
|
||||
{
|
||||
if (uip_poll())
|
||||
{
|
||||
++s->timer;
|
||||
if(s->timer >= 20) {
|
||||
if (s->timer >= 20)
|
||||
{
|
||||
uip_abort();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
s->timer = 0;
|
||||
}
|
||||
handle_connection(s);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
uip_abort();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@
|
|||
#include "psock.h"
|
||||
#include "httpd-fs.h"
|
||||
|
||||
struct httpd_state {
|
||||
struct httpd_state
|
||||
{
|
||||
unsigned char timer;
|
||||
struct psock sin, sout;
|
||||
struct pt outputpt, scriptpt;
|
||||
|
|
|
@ -25,49 +25,62 @@ main(void)
|
|||
|
||||
httpd_init();
|
||||
|
||||
while(1) {
|
||||
while (1)
|
||||
{
|
||||
uip_len = network_device_read();
|
||||
if(uip_len > 0) {
|
||||
if(BUF->type == htons(UIP_ETHTYPE_IP)) {
|
||||
if (uip_len > 0)
|
||||
{
|
||||
if (BUF->type == htons(UIP_ETHTYPE_IP))
|
||||
{
|
||||
uip_arp_ipin();
|
||||
uip_input();
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if(uip_len > 0) {
|
||||
if (uip_len > 0)
|
||||
{
|
||||
uip_arp_out();
|
||||
network_device_send();
|
||||
}
|
||||
} else if(BUF->type == htons(UIP_ETHTYPE_ARP)) {
|
||||
}
|
||||
else if (BUF->type == htons(UIP_ETHTYPE_ARP))
|
||||
{
|
||||
uip_arp_arpin();
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if(uip_len > 0) {
|
||||
if (uip_len > 0)
|
||||
{
|
||||
network_device_send();
|
||||
}
|
||||
}
|
||||
|
||||
} else if(timer_expired(&periodic_timer)) {
|
||||
}
|
||||
else if (timer_expired(&periodic_timer))
|
||||
{
|
||||
timer_reset(&periodic_timer);
|
||||
for(i = 0; i < UIP_CONNS; i++) {
|
||||
for (i = 0; i < UIP_CONNS; i++)
|
||||
{
|
||||
uip_periodic(i);
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if(uip_len > 0) {
|
||||
if (uip_len > 0)
|
||||
{
|
||||
uip_arp_out();
|
||||
network_device_send();
|
||||
}
|
||||
}
|
||||
|
||||
#if UIP_UDP
|
||||
for(i = 0; i < UIP_UDP_CONNS; i++) {
|
||||
for (i = 0; i < UIP_UDP_CONNS; i++)
|
||||
{
|
||||
uip_udp_periodic(i);
|
||||
/* If the above function invocation resulted in data that
|
||||
should be sent out on the network, the global variable
|
||||
uip_len is set to a value > 0. */
|
||||
if(uip_len > 0) {
|
||||
if (uip_len > 0)
|
||||
{
|
||||
uip_arp_out();
|
||||
network_device_send();
|
||||
}
|
||||
|
@ -75,7 +88,8 @@ main(void)
|
|||
#endif /* UIP_UDP */
|
||||
|
||||
/* Call the ARP timer function every 10 seconds. */
|
||||
if(timer_expired(&arp_timer)) {
|
||||
if (timer_expired(&arp_timer))
|
||||
{
|
||||
timer_reset(&arp_timer);
|
||||
uip_arp_timer();
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue