Fix formatting errors

pull/936/head
Rahul Kar 12 months ago
parent 92a502b03f
commit cf1b977eee

@ -1,6 +1,6 @@
/* /*
* FreeRTOS V202212.00 * FreeRTOS V202212.00
* Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in

@ -1,6 +1,6 @@
/* /*
* FreeRTOS V202212.00 * FreeRTOS V202212.00
* Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in

@ -1,6 +1,6 @@
/* /*
* FreeRTOS V202212.00 * FreeRTOS V202212.00
* Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in

@ -1,6 +1,6 @@
/* /*
* FreeRTOS V202212.00 * FreeRTOS V202212.00
* Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in

@ -1,6 +1,6 @@
/* /*
* FreeRTOS V202212.00 * FreeRTOS V202212.00
* Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@ -31,16 +31,17 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ); void vApplicationStackOverflowHook( TaskHandle_t pxTask,
char * pcTaskName );
void vApplicationMallocFailedHook( void ); void vApplicationMallocFailedHook( void );
void vMainMQTTClientTasks( void ); void vMainMQTTClientTasks( void );
void vApplicationIdleHook( void ); void vApplicationIdleHook( void );
void vApplicationTickHook( void ); void vApplicationTickHook( void );
extern void initialise_monitor_handles( void ); extern void initialise_monitor_handles( void );
extern void vStartupTask( void* pvParameters ); extern void vStartupTask( void * pvParameters );
int main () int main()
{ {
initialise_monitor_handles(); initialise_monitor_handles();
@ -51,14 +52,16 @@ int main ()
NULL, NULL,
1U, 1U,
NULL NULL
); );
vTaskStartScheduler(); vTaskStartScheduler();
// The code should never reach here. /* The code should never reach here. */
configASSERT( 0 ); configASSERT( 0 );
for ( ;; ) {} for( ; ; )
{
}
return 0; return 0;
} }
@ -68,39 +71,46 @@ int main ()
void vApplicationMallocFailedHook( void ) void vApplicationMallocFailedHook( void )
{ {
/* Called if a call to pvPortMalloc() fails because there is insufficient /* Called if a call to pvPortMalloc() fails because there is insufficient
free memory available in the FreeRTOS heap. pvPortMalloc() is called * free memory available in the FreeRTOS heap. pvPortMalloc() is called
internally by FreeRTOS API functions that create tasks, queues, software * internally by FreeRTOS API functions that create tasks, queues, software
timers, and semaphores. The size of the FreeRTOS heap is set by the * timers, and semaphores. The size of the FreeRTOS heap is set by the
configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */ * configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */
taskDISABLE_INTERRUPTS(); taskDISABLE_INTERRUPTS();
for( ;; ){};
for( ; ; )
{
}
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ) void vApplicationStackOverflowHook( TaskHandle_t pxTask,
char * pcTaskName )
{ {
( void ) pcTaskName; ( void ) pcTaskName;
( void ) pxTask; ( void ) pxTask;
/* Run time stack overflow checking is performed if /* Run time stack overflow checking is performed if
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook * configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook
function is called if a stack overflow is detected. */ * function is called if a stack overflow is detected. */
taskDISABLE_INTERRUPTS(); taskDISABLE_INTERRUPTS();
for( ;; ){};
for( ; ; )
{
}
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vApplicationIdleHook( void ) void vApplicationIdleHook( void )
{ {
volatile size_t xFreeHeapSpace; volatile size_t xFreeHeapSpace;
/* This is just a trivial example of an idle hook. It is called on each /* This is just a trivial example of an idle hook. It is called on each
cycle of the idle task. It must *NOT* attempt to block. In this case the * cycle of the idle task. It must *NOT* attempt to block. In this case the
idle task just queries the amount of FreeRTOS heap that remains. See the * idle task just queries the amount of FreeRTOS heap that remains. See the
memory management section on the https://www.FreeRTOS.org web site for memory * memory management section on the https://www.FreeRTOS.org web site for memory
management options. If there is a lot of heap memory free then the * management options. If there is a lot of heap memory free then the
configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up * configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up
RAM. */ * RAM. */
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -112,10 +122,11 @@ void vApplicationTickHook( void )
void vAssertCalled( void ) void vAssertCalled( void )
{ {
volatile unsigned long looping = 0; volatile unsigned long looping = 0;
taskENTER_CRITICAL(); taskENTER_CRITICAL();
{ {
/* Use the debugger to set looping to a non-zero value in order to step out /* Use the debugger to set looping to a non-zero value in order to step
of this function to determine why it was called. */ * out of this function to determine why it was called. */
while( looping == 0LU ) while( looping == 0LU )
{ {
portNOP(); portNOP();
@ -124,13 +135,14 @@ void vAssertCalled( void )
taskEXIT_CRITICAL(); taskEXIT_CRITICAL();
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vLoggingPrintf( const char *pcFormat, ... ) void vLoggingPrintf( const char * pcFormat,
... )
{ {
va_list arg; va_list arg;
va_start( arg, pcFormat ); va_start( arg, pcFormat );
vprintf( pcFormat, arg ); vprintf( pcFormat, arg );
va_end( arg ); va_end( arg );
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/

@ -1,6 +1,6 @@
/* /*
* FreeRTOS V202212.00 * FreeRTOS V202212.00
* Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@ -185,7 +185,6 @@ void vPlatformInitIpStack( void )
{ {
BaseType_t xResult; BaseType_t xResult;
uint8_t ucIPAddress[ 4 ]; uint8_t ucIPAddress[ 4 ];
uint8_t ucNetMask[ 4 ] = { configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 };
uint8_t ucNullAddress[ 4 ] = { 0, 0, 0, 0 }; uint8_t ucNullAddress[ 4 ] = { 0, 0, 0, 0 };
uint8_t ucMACAddress[ 6 ]; uint8_t ucMACAddress[ 6 ];
uint8_t ucDNSServerAddress[ 4 ]; uint8_t ucDNSServerAddress[ 4 ];

@ -37,48 +37,50 @@ extern void xPortSysTickHandler( void );
extern void uart_init(); extern void uart_init();
extern int main(); extern int main();
void __attribute__((weak)) EthernetISR (void); void __attribute__( ( weak ) ) EthernetISR( void );
extern uint32_t _estack, _sidata, _sdata, _edata, _sbss, _ebss; extern uint32_t _estack, _sidata, _sdata, _edata, _sbss, _ebss;
/* Prevent optimization so gcc does not replace code with memcpy */ /* Prevent optimization so gcc does not replace code with memcpy */
__attribute__((optimize("O0"))) __attribute__( ( optimize( "O0" ) ) )
__attribute__((naked)) __attribute__( ( naked ) )
void Reset_Handler(void) void Reset_Handler( void )
{ {
// set stack pointer /* set stack pointer */
__asm volatile ("ldr r0, =_estack"); __asm volatile ( "ldr r0, =_estack" );
__asm volatile ("mov sp, r0"); __asm volatile ( "mov sp, r0" );
// copy .data section from flash to RAM
for (uint32_t *src = &_sidata, *dest = &_sdata; dest < &_edata;) /* copy .data section from flash to RAM */
for( uint32_t * src = &_sidata, * dest = &_sdata; dest < &_edata; )
{ {
*dest++ = *src++; *dest++ = *src++;
} }
// zero out .bss section /* zero out .bss section */
for (uint32_t *dest = &_sbss; dest < &_ebss;) for( uint32_t * dest = &_sbss; dest < &_ebss; )
{ {
*dest++ = 0; *dest++ = 0;
} }
// jump to board initialisation
void _start(void); /* jump to board initialisation */
void _start( void );
_start(); _start();
} }
void prvGetRegistersFromStack( uint32_t *pulFaultStackAddress ) void prvGetRegistersFromStack( uint32_t * pulFaultStackAddress )
{ {
/* These are volatile to try and prevent the compiler/linker optimising them /* These are volatile to try and prevent the compiler/linker optimising them
away as the variables never actually get used. If the debugger won't show the * away as the variables never actually get used. If the debugger won't show the
values of the variables, make them global my moving their declaration outside * values of the variables, make them global my moving their declaration outside
of this function. */ * of this function. */
volatile uint32_t r0; volatile uint32_t r0;
volatile uint32_t r1; volatile uint32_t r1;
volatile uint32_t r2; volatile uint32_t r2;
volatile uint32_t r3; volatile uint32_t r3;
volatile uint32_t r12; volatile uint32_t r12;
volatile uint32_t lr; /* Link register. */ volatile uint32_t lr; /* Link register. */
volatile uint32_t pc; /* Program counter. */ volatile uint32_t pc; /* Program counter. */
volatile uint32_t psr;/* Program status register. */ volatile uint32_t psr; /* Program status register. */
r0 = pulFaultStackAddress[ 0 ]; r0 = pulFaultStackAddress[ 0 ];
r1 = pulFaultStackAddress[ 1 ]; r1 = pulFaultStackAddress[ 1 ];
@ -91,11 +93,13 @@ of this function. */
psr = pulFaultStackAddress[ 7 ]; psr = pulFaultStackAddress[ 7 ];
/* When the following line is hit, the variables contain the register values. */ /* When the following line is hit, the variables contain the register values. */
for( ;; ); for( ; ; )
{
}
} }
static void Default_Handler( void ) __attribute__( ( naked ) ); static void Default_Handler( void ) __attribute__( ( naked ) );
void Default_Handler(void) void Default_Handler( void )
{ {
__asm volatile __asm volatile
( (
@ -111,9 +115,8 @@ void Default_Handler(void)
); );
} }
static void HardFault_Handler( void ) __attribute__( ( naked ) ); static void HardFault_Handler( void ) __attribute__( ( naked ) );
void Default_Handler2(void) void Default_Handler2( void )
{ {
__asm volatile __asm volatile
( (
" tst lr, #4 \n" " tst lr, #4 \n"
@ -127,79 +130,86 @@ void Default_Handler2(void)
); );
} }
void Default_Handler3(void) void Default_Handler3( void )
{ {
for (;;) { } for( ; ; )
{
}
} }
void Default_Handler4(void) void Default_Handler4( void )
{ {
for (;;) { } for( ; ; )
{
}
} }
void Default_Handler5(void) void Default_Handler5( void )
{ {
for (;;) { } for( ; ; )
{
}
} }
void Default_Handler6(void) void Default_Handler6( void )
{ {
for (;;) { } for( ; ; )
{
}
} }
const uint32_t* isr_vector[] __attribute__((section(".isr_vector"))) = const uint32_t * isr_vector[] __attribute__( ( section( ".isr_vector" ) ) ) =
{ {
(uint32_t*)&_estack, ( uint32_t * ) &_estack,
(uint32_t*)&Reset_Handler, // Reset -15 ( uint32_t * ) &Reset_Handler, /* Reset -15 */
(uint32_t*)&Default_Handler, // NMI_Handler -14 ( uint32_t * ) &Default_Handler, /* NMI_Handler -14 */
(uint32_t*)&Default_Handler2, // HardFault_Handler -13 ( uint32_t * ) &Default_Handler2, /* HardFault_Handler -13 */
(uint32_t*)&Default_Handler3, // MemManage_Handler -12 ( uint32_t * ) &Default_Handler3, /* MemManage_Handler -12 */
(uint32_t*)&Default_Handler4, // BusFault_Handler -11 ( uint32_t * ) &Default_Handler4, /* BusFault_Handler -11 */
(uint32_t*)&Default_Handler5, // UsageFault_Handler -10 ( uint32_t * ) &Default_Handler5, /* UsageFault_Handler -10 */
0, // reserved 0, /* reserved */
0, // reserved 0, /* reserved */
0, // reserved 0, /* reserved */
0, // reserved -6 0, /* reserved -6 */
(uint32_t*)&vPortSVCHandler, // SVC_Handler -5 ( uint32_t * ) &vPortSVCHandler, /* SVC_Handler -5 */
(uint32_t*)&Default_Handler6, // DebugMon_Handler -4 ( uint32_t * ) &Default_Handler6, /* DebugMon_Handler -4 */
0, // reserved 0, /* reserved */
(uint32_t*)&xPortPendSVHandler, // PendSV handler -2 ( uint32_t * ) &xPortPendSVHandler, /* PendSV handler -2 */
(uint32_t*)&xPortSysTickHandler, // SysTick_Handler -1 ( uint32_t * ) &xPortSysTickHandler, /* SysTick_Handler -1 */
0, // uart0 receive 0 0, /* uart0 receive 0 */
0, // uart0 transmit 0, /* uart0 transmit */
0, // uart1 receive 0, /* uart1 receive */
0, // uart1 transmit 0, /* uart1 transmit */
0, // uart 2 receive 0, /* uart 2 receive */
0, // uart 2 transmit 0, /* uart 2 transmit */
0, // GPIO 0 combined interrupt 0, /* GPIO 0 combined interrupt */
0, // GPIO 2 combined interrupt 0, /* GPIO 2 combined interrupt */
0, // Timer 0 0, /* Timer 0 */
0, // Timer 1 0, /* Timer 1 */
0, // Dial Timer 0, /* Dial Timer */
0, // SPI0 SPI1 0, /* SPI0 SPI1 */
0, // uart overflow 1 2,3 12 0, /* uart overflow 1 2,3 12 */
(uint32_t*)&EthernetISR, // Ethernet 13 ( uint32_t * ) &EthernetISR, /* Ethernet 13 */
}; };
void _start(void) void _start( void )
{ {
uart_init(); uart_init();
main(0, 0); main( 0, 0 );
exit(0); exit( 0 );
} }
__attribute__((naked)) void exit(int status) __attribute__( ( naked ) ) void exit( int status )
{ {
// Force qemu to exit using ARM Semihosting /* Force qemu to exit using ARM Semihosting */
__asm volatile ( __asm volatile (
"mov r1, r0\n" "mov r1, r0\n"
"cmp r1, #0\n" "cmp r1, #0\n"
"bne .notclean\n" "bne .notclean\n"
"ldr r1, =0x20026\n" // ADP_Stopped_ApplicationExit, a clean exit "ldr r1, =0x20026\n" /* ADP_Stopped_ApplicationExit, a clean exit */
".notclean:\n" ".notclean:\n"
"movs r0, #0x18\n" // SYS_EXIT "movs r0, #0x18\n" /* SYS_EXIT */
"bkpt 0xab\n" "bkpt 0xab\n"
"end: b end\n" "end: b end\n"
); );
} }

@ -1,6 +1,6 @@
/* /*
* FreeRTOS V202212.00 * FreeRTOS V202212.00
* Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * Copyright (C) 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@ -29,7 +29,8 @@ extern "C" {
#include <sys/types.h> #include <sys/types.h>
typedef struct UART_t { typedef struct UART_t
{
volatile uint32_t DATA; volatile uint32_t DATA;
volatile uint32_t STATE; volatile uint32_t STATE;
volatile uint32_t CTRL; volatile uint32_t CTRL;
@ -37,19 +38,19 @@ typedef struct UART_t {
volatile uint32_t BAUDDIV; volatile uint32_t BAUDDIV;
} UART_t; } UART_t;
#define UART0_ADDR ((UART_t *)(0x40004000)) #define UART0_ADDR ( ( UART_t * ) ( 0x40004000 ) )
#define UART_DR(baseaddr) (*(unsigned int *)(baseaddr)) #define UART_DR( baseaddr ) ( *( unsigned int * ) ( baseaddr ) )
#define UART_STATE_TXFULL (1 << 0) #define UART_STATE_TXFULL ( 1 << 0 )
#define UART_CTRL_TX_EN (1 << 0) #define UART_CTRL_TX_EN ( 1 << 0 )
#define UART_CTRL_RX_EN (1 << 1) #define UART_CTRL_RX_EN ( 1 << 1 )
extern unsigned long _heap_bottom; extern unsigned long _heap_bottom;
extern unsigned long _heap_top; extern unsigned long _heap_top;
extern unsigned long g_ulBase; extern unsigned long g_ulBase;
static void *heap_end = 0; static void * heap_end = 0;
/** /**
* @brief initializes the UART emulated hardware * @brief initializes the UART emulated hardware
@ -65,7 +66,7 @@ void uart_init()
* @todo implement if necessary * @todo implement if necessary
* *
*/ */
int _fstat(int file) int _fstat( int file )
{ {
return 0; return 0;
} }
@ -75,9 +76,11 @@ int _fstat(int file)
* @todo implement if necessary * @todo implement if necessary
* *
*/ */
int _read(int file, char *buf, int len) int _read( int file,
char * buf,
int len )
{ {
return -1; return -1;
} }
/** /**
@ -88,13 +91,17 @@ int _read(int file, char *buf, int len)
* @param [in] len length of the buffer * @param [in] len length of the buffer
* @returns the number of bytes written * @returns the number of bytes written
*/ */
int _write(int file, char *buf, int len) int _write( int file,
char * buf,
int len )
{ {
int todo; int todo;
for (todo = 0; todo < len; todo++){ for( todo = 0; todo < len; todo++ )
UART_DR(UART0_ADDR) = *buf++; {
UART_DR( UART0_ADDR ) = *buf++;
} }
return len; return len;
} }
@ -104,20 +111,20 @@ int _write(int file, char *buf, int len)
* @returns the previous top of the heap * @returns the previous top of the heap
* @note uses a global variable <b>heap_end</b> to keep track of the previous top * @note uses a global variable <b>heap_end</b> to keep track of the previous top
*/ */
void* _sbrk(int incr) void * _sbrk( int incr )
{ {
char *prev_heap_end; char * prev_heap_end;
if (heap_end == 0) if( heap_end == 0 )
{ {
heap_end = (void*) &_heap_bottom; heap_end = ( void * ) &_heap_bottom;
} }
prev_heap_end = heap_end; prev_heap_end = heap_end;
if ((heap_end + incr) > (void*)&_heap_top) if( ( heap_end + incr ) > ( void * ) &_heap_top )
{ {
return (void*)-1; return ( void * ) -1;
} }
heap_end += incr; heap_end += incr;

Loading…
Cancel
Save