mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-17 15:38:14 +08:00
修复mico-sdk错误
This commit is contained in:
@@ -6,170 +6,170 @@
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
*
|
||||
*/
|
||||
|
||||
Reset_Handler = _start;
|
||||
|
||||
ENTRY( _start );
|
||||
|
||||
/* Include memory map */
|
||||
INCLUDE memory.ld
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
/* Data transfer area for serial flash writing app - at start of memory */
|
||||
.sflash_trnsf :
|
||||
{
|
||||
KEEP(*(*.data_config))
|
||||
KEEP(*(*.data_transfer))
|
||||
}>SRAM AT> SRAM
|
||||
|
||||
|
||||
.vectors :
|
||||
{
|
||||
. = ALIGN(512);
|
||||
link_interrupt_vectors_location = .;
|
||||
KEEP(*(*.interrupt_vector_table))
|
||||
}>SRAM AT> SRAM
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
|
||||
link_code_location = .;
|
||||
KEEP(*(.text.irq ))
|
||||
*(.text .text.* .gnu.linkonce.t.*)
|
||||
link_code_end = .;
|
||||
|
||||
. = ALIGN(0x4);
|
||||
|
||||
link_const_variable_data_location = .;
|
||||
wifi_firmware_image_location = .;
|
||||
*(.rodata.wifi_firmware_image)
|
||||
wifi_firmware_image_end = .;
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
link_const_variable_data_end = .;
|
||||
|
||||
. = ALIGN(0x4);
|
||||
|
||||
link_constructors_location = .;
|
||||
KEEP(*(.preinit_array))
|
||||
KEEP(*(.init_array))
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*crtend.o(.ctors))
|
||||
link_constructors_end = .;
|
||||
|
||||
. = ALIGN(0x4);
|
||||
|
||||
link_destructors_location = .;
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*crtend.o(.dtors))
|
||||
link_destructors_end = .;
|
||||
|
||||
. = ALIGN(16);
|
||||
|
||||
}>SRAM AT> SRAM
|
||||
|
||||
/*
|
||||
* The .ARM.exidx and .ARM.exidx sections are used for C++ exception handling.
|
||||
* It is located here for completeness. Bare-metal ARM projects
|
||||
* typically cannot afford the overhead associated with C++
|
||||
* exceptions handling.
|
||||
*/
|
||||
.ARM.exidx :
|
||||
{
|
||||
__exidx_start = ALIGN(4);
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
__exidx_end = .;
|
||||
} >SRAM AT> SRAM
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
__extab_start = ALIGN(4);
|
||||
*(.ARM.extab*)
|
||||
__extab_end = .;
|
||||
} > SRAM AT> SRAM
|
||||
|
||||
.fast : /* This section contains code that is run from RAM after being loaded from flash - functions can be put in this section with the C attribute: __attribute__ ((section (".fast"))) */
|
||||
{
|
||||
link_run_from_ram_code_flash_location = LOADADDR( .fast ); /* This is the location in flash of the code */
|
||||
link_run_from_ram_code_ram_location = .;
|
||||
*(.fast .fast.* .text.fastcode)
|
||||
link_run_from_ram_code_ram_end = .;
|
||||
}>SRAM AT> SRAM
|
||||
|
||||
.data : /* Contains the non-zero initialised global variables */
|
||||
{
|
||||
link_global_data_initial_values = LOADADDR( .data ); /* This is the location in flash of the initial values of global variables */
|
||||
link_global_data_start = .;
|
||||
*(.data*)
|
||||
link_global_data_end = .;
|
||||
. = ALIGN(., 4);
|
||||
}>SRAM AT> SRAM
|
||||
|
||||
|
||||
.bss : /* Zero initialised memory used for zero initialised variables */
|
||||
{
|
||||
link_bss_location = ALIGN(., 4);
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
link_bss_end = .;
|
||||
. = ALIGN(., 4);
|
||||
}> SRAM AT> SRAM
|
||||
|
||||
|
||||
.stack : /* Contains the initial stack */
|
||||
{
|
||||
link_stack_location = ALIGN(., 4);
|
||||
*(.stack)
|
||||
. = ALIGN(MAX(link_stack_location + __STACKSIZE__ , .), 4);
|
||||
link_stack_end = .;
|
||||
}> SRAM AT> SRAM
|
||||
|
||||
/DISCARD/ :
|
||||
{
|
||||
*(.ARM.attributes*)
|
||||
*(.comment)
|
||||
*(.init)
|
||||
*(.preinit)
|
||||
*(.fini)
|
||||
*(.fini_array)
|
||||
*(.ARM.exidx*)
|
||||
*(.gnu.linkonce.armexidx.*)
|
||||
*(.eh_frame_hdr)
|
||||
*(.eh_frame)
|
||||
*(.gnu.linkonce.armextab.*)
|
||||
*(.v4_bx)
|
||||
*(.vfp11_veneer)
|
||||
*(.gcc_except_table)
|
||||
*(.eh_frame_hdr)
|
||||
*(.eh_frame)
|
||||
*(.glue*)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Declare libc Heap to start at end of allocated RAM */
|
||||
|
||||
PROVIDE( _heap = link_stack_end );
|
||||
|
||||
/* End of the heap is top of RAM, aligned 8 byte */
|
||||
|
||||
PROVIDE( _eheap = ALIGN( ORIGIN( SRAM ) + LENGTH( SRAM ) - 8, 8 ) );
|
||||
PROVIDE( total_app_image_size = LOADADDR( .data ) - ORIGIN( SRAM ) + link_global_data_end - link_global_data_start );
|
||||
PROVIDE( wifi_firmware_image_size_from_link = wifi_firmware_image_end - wifi_firmware_image_location );
|
||||
|
||||
/* ThreadX aliases */
|
||||
PROVIDE( __RAM_segment_used_end__ = link_stack_end );
|
||||
PROVIDE( __tx_free_memory_start = link_stack_end );
|
||||
PROVIDE( __tx_vectors = link_interrupt_vectors_location );
|
||||
|
||||
PROVIDE( wifi_firmware_image = 0 );
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
Reset_Handler = _start;
|
||||
|
||||
ENTRY( _start );
|
||||
|
||||
/* Include memory map */
|
||||
INCLUDE memory.ld
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
/* Data transfer area for serial flash writing app - at start of memory */
|
||||
.sflash_trnsf :
|
||||
{
|
||||
KEEP(*(*.data_config))
|
||||
KEEP(*(*.data_transfer))
|
||||
}>SRAM AT> SRAM
|
||||
|
||||
|
||||
.vectors :
|
||||
{
|
||||
. = ALIGN(512);
|
||||
link_interrupt_vectors_location = .;
|
||||
KEEP(*(*.interrupt_vector_table))
|
||||
}>SRAM AT> SRAM
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
|
||||
link_code_location = .;
|
||||
KEEP(*(.text.irq ))
|
||||
*(.text .text.* .gnu.linkonce.t.*)
|
||||
link_code_end = .;
|
||||
|
||||
. = ALIGN(0x4);
|
||||
|
||||
link_const_variable_data_location = .;
|
||||
wifi_firmware_image_location = .;
|
||||
*(.rodata.wifi_firmware_image)
|
||||
wifi_firmware_image_end = .;
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
link_const_variable_data_end = .;
|
||||
|
||||
. = ALIGN(0x4);
|
||||
|
||||
link_constructors_location = .;
|
||||
KEEP(*(.preinit_array))
|
||||
KEEP(*(.init_array))
|
||||
KEEP (*crtbegin.o(.ctors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
|
||||
KEEP (*(SORT(.ctors.*)))
|
||||
KEEP (*crtend.o(.ctors))
|
||||
link_constructors_end = .;
|
||||
|
||||
. = ALIGN(0x4);
|
||||
|
||||
link_destructors_location = .;
|
||||
KEEP (*crtbegin.o(.dtors))
|
||||
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
|
||||
KEEP (*(SORT(.dtors.*)))
|
||||
KEEP (*crtend.o(.dtors))
|
||||
link_destructors_end = .;
|
||||
|
||||
. = ALIGN(16);
|
||||
|
||||
}>SRAM AT> SRAM
|
||||
|
||||
/*
|
||||
* The .ARM.exidx and .ARM.exidx sections are used for C++ exception handling.
|
||||
* It is located here for completeness. Bare-metal ARM projects
|
||||
* typically cannot afford the overhead associated with C++
|
||||
* exceptions handling.
|
||||
*/
|
||||
.ARM.exidx :
|
||||
{
|
||||
__exidx_start = ALIGN(4);
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
__exidx_end = .;
|
||||
} >SRAM AT> SRAM
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
__extab_start = ALIGN(4);
|
||||
*(.ARM.extab*)
|
||||
__extab_end = .;
|
||||
} > SRAM AT> SRAM
|
||||
|
||||
.fast : /* This section contains code that is run from RAM after being loaded from flash - functions can be put in this section with the C attribute: __attribute__ ((section (".fast"))) */
|
||||
{
|
||||
link_run_from_ram_code_flash_location = LOADADDR( .fast ); /* This is the location in flash of the code */
|
||||
link_run_from_ram_code_ram_location = .;
|
||||
*(.fast .fast.* .text.fastcode)
|
||||
link_run_from_ram_code_ram_end = .;
|
||||
}>SRAM AT> SRAM
|
||||
|
||||
.data : /* Contains the non-zero initialised global variables */
|
||||
{
|
||||
link_global_data_initial_values = LOADADDR( .data ); /* This is the location in flash of the initial values of global variables */
|
||||
link_global_data_start = .;
|
||||
*(.data*)
|
||||
link_global_data_end = .;
|
||||
. = ALIGN(., 4);
|
||||
}>SRAM AT> SRAM
|
||||
|
||||
|
||||
.bss : /* Zero initialised memory used for zero initialised variables */
|
||||
{
|
||||
link_bss_location = ALIGN(., 4);
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
link_bss_end = .;
|
||||
. = ALIGN(., 4);
|
||||
}> SRAM AT> SRAM
|
||||
|
||||
|
||||
.stack : /* Contains the initial stack */
|
||||
{
|
||||
link_stack_location = ALIGN(., 4);
|
||||
*(.stack)
|
||||
. = ALIGN(MAX(link_stack_location + __STACKSIZE__ , .), 4);
|
||||
link_stack_end = .;
|
||||
}> SRAM AT> SRAM
|
||||
|
||||
/DISCARD/ :
|
||||
{
|
||||
*(.ARM.attributes*)
|
||||
*(.comment)
|
||||
*(.init)
|
||||
*(.preinit)
|
||||
*(.fini)
|
||||
*(.fini_array)
|
||||
*(.ARM.exidx*)
|
||||
*(.gnu.linkonce.armexidx.*)
|
||||
*(.eh_frame_hdr)
|
||||
*(.eh_frame)
|
||||
*(.gnu.linkonce.armextab.*)
|
||||
*(.v4_bx)
|
||||
*(.vfp11_veneer)
|
||||
*(.gcc_except_table)
|
||||
*(.eh_frame_hdr)
|
||||
*(.eh_frame)
|
||||
*(.glue*)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Declare libc Heap to start at end of allocated RAM */
|
||||
|
||||
PROVIDE( _heap = link_stack_end );
|
||||
|
||||
/* End of the heap is top of RAM, aligned 8 byte */
|
||||
|
||||
PROVIDE( _eheap = ALIGN( ORIGIN( SRAM ) + LENGTH( SRAM ) - 8, 8 ) );
|
||||
PROVIDE( total_app_image_size = LOADADDR( .data ) - ORIGIN( SRAM ) + link_global_data_end - link_global_data_start );
|
||||
PROVIDE( wifi_firmware_image_size_from_link = wifi_firmware_image_end - wifi_firmware_image_location );
|
||||
|
||||
/* ThreadX aliases */
|
||||
PROVIDE( __RAM_segment_used_end__ = link_stack_end );
|
||||
PROVIDE( __tx_free_memory_start = link_stack_end );
|
||||
PROVIDE( __tx_vectors = link_interrupt_vectors_location );
|
||||
|
||||
PROVIDE( wifi_firmware_image = 0 );
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,220 +1,220 @@
|
||||
/*
|
||||
* Script for GNU linker.
|
||||
* Describes layout of sections, location of stack.
|
||||
*
|
||||
* In this case vectors are at location 0 (reset @ 0x08)
|
||||
*
|
||||
*
|
||||
*
|
||||
* +------------+ 0x0040000
|
||||
* Vect redirect 32
|
||||
* +------------+
|
||||
*
|
||||
* +------------+ 0x00400020
|
||||
* data |
|
||||
* end
|
||||
* |(heap) |
|
||||
* . .
|
||||
* . .
|
||||
* |(heap limit)|
|
||||
*
|
||||
* |- - - - - - |
|
||||
* stack bottom 256k
|
||||
* +------------+
|
||||
*
|
||||
*
|
||||
* +------------+ 0x0000000
|
||||
* |Bootloader |
|
||||
* | | 64k
|
||||
* +------------+ 0x0010000
|
||||
* | Para 1 | 4k
|
||||
* +------------+
|
||||
* | Para 2 | 4k
|
||||
* +------------+ 0x0012000
|
||||
* |vectors |
|
||||
* | |
|
||||
* |------------+
|
||||
* |text |
|
||||
* |data | 632k
|
||||
* | |
|
||||
* +------------+
|
||||
*
|
||||
*
|
||||
* +------------+ 0x00B0000
|
||||
* | |
|
||||
* | |
|
||||
* | OTA TEMP |
|
||||
* | |
|
||||
* | |
|
||||
* | | 320k
|
||||
* +------------+
|
||||
*/
|
||||
|
||||
|
||||
/* Split memory into area for vectors and ram */
|
||||
MEMORY
|
||||
{
|
||||
flash (rx) : ORIGIN = 0x0012000, LENGTH = 546936
|
||||
ram (rwx): ORIGIN = 0x00400020, LENGTH = 256k - 32
|
||||
}
|
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(_vector_start);
|
||||
_vector_start = 0x0012000;
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* vectors go to vectors region */
|
||||
. = 0x0012000;
|
||||
.vectors :
|
||||
{
|
||||
KEEP(*(*.vectors))
|
||||
} > flash
|
||||
|
||||
/* instructions go to the text region*/
|
||||
|
||||
. = ALIGN(0x8);
|
||||
/* code, instructions.for example: i=i+1; */
|
||||
.text :
|
||||
{
|
||||
*(.text*)
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
*(.rodata*)
|
||||
KEEP(*(.eh_frame*))
|
||||
|
||||
} > flash
|
||||
|
||||
.ARM.extab ALIGN(8) :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > flash
|
||||
|
||||
.ARM.exidx ALIGN(8):
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
} > flash
|
||||
|
||||
_begin_data = .;
|
||||
.data : AT ( _begin_data )
|
||||
{
|
||||
__data_start__ = .;
|
||||
_sdata = .;
|
||||
*(.data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
KEEP(*(.jcr*))
|
||||
SORT(CONSTRUCTORS)
|
||||
|
||||
/* All data end */
|
||||
__data_end__ = .;
|
||||
_edata = .;
|
||||
|
||||
KEEP(*(.dummydata))
|
||||
} >ram
|
||||
|
||||
/* Loader will copy data from _flash_begin to _ram_begin..ram_end */
|
||||
_data_flash_begin = LOADADDR(.data);
|
||||
_data_ram_begin = ADDR(.data);
|
||||
_data_ram_end = .;
|
||||
|
||||
/* uninitialized data section - global int i; */
|
||||
.bss ALIGN(8):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_bss_start = .;
|
||||
__bss_start__ = .;
|
||||
_sbss = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
_bss_end = .;
|
||||
__bss_end__ = .;
|
||||
_ebss = .;
|
||||
} > ram /* in RAM */
|
||||
|
||||
. = ALIGN (8);
|
||||
_empty_ram = .;
|
||||
|
||||
/* This symbol defines end of code/data sections. Heap starts here. */
|
||||
PROVIDE(end = .);
|
||||
PROVIDE(_heap_start = .);
|
||||
|
||||
.heap (COPY):
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
*(.heap*)
|
||||
__HeapLimit = .;
|
||||
} > ram
|
||||
|
||||
.stack_dummy (COPY):
|
||||
{
|
||||
*(.stack*)
|
||||
} > ram
|
||||
|
||||
/* _stack symbol defines initial stack bottom addres. Stack grows to lower addresses.
|
||||
Typically you set this to be top of your RAM. Note: code never checks, if stack
|
||||
grows into heap area!
|
||||
*/
|
||||
PROVIDE(_stack_unused = 0x440000 - 0x3F0 - 0x7F0 - 0xFF0 - 0x3F0 - 0x10); /* 0x10*/
|
||||
PROVIDE(_stack_svc = 0x440000 - 0x3F0 - 0x7F0 - 0xFF0 - 0x3F0); /* 0x3F0*/
|
||||
PROVIDE(_stack_irq = 0x440000 - 0x3F0 - 0x7F0 - 0xFF0); /* 0xFF0*/
|
||||
PROVIDE(_stack_fiq = 0x440000 - 0x3F0 - 0x7F0); /* 0x7F0*/
|
||||
PROVIDE(_stack_sys = 0x440000 - 0x3F0); /* 0x3F0*/
|
||||
|
||||
PROVIDE(_heap_end = _stack_unused);
|
||||
PROVIDE(_heap_len = _heap_end - _heap_start);
|
||||
|
||||
ASSERT ((_heap_len > 0x19000 - 1 ), "Error: No room left for the heap") /*heap must bigger than 100k*/
|
||||
|
||||
__StackTop = ORIGIN(ram) + LENGTH(ram);
|
||||
_estack = __StackTop;
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
PROVIDE(__stack = __StackTop);
|
||||
|
||||
}
|
||||
GROUP(
|
||||
libstdc++.a
|
||||
libsupc++.a
|
||||
libgcc.a
|
||||
libg.a
|
||||
libc.a
|
||||
libm.a
|
||||
libnosys.a
|
||||
/*
|
||||
* Script for GNU linker.
|
||||
* Describes layout of sections, location of stack.
|
||||
*
|
||||
* In this case vectors are at location 0 (reset @ 0x08)
|
||||
*
|
||||
*
|
||||
*
|
||||
* +------------+ 0x0040000
|
||||
* Vect redirect 32
|
||||
* +------------+
|
||||
*
|
||||
* +------------+ 0x00400020
|
||||
* data |
|
||||
* end
|
||||
* |(heap) |
|
||||
* . .
|
||||
* . .
|
||||
* |(heap limit)|
|
||||
*
|
||||
* |- - - - - - |
|
||||
* stack bottom 256k
|
||||
* +------------+
|
||||
*
|
||||
*
|
||||
* +------------+ 0x0000000
|
||||
* |Bootloader |
|
||||
* | | 64k
|
||||
* +------------+ 0x0010000
|
||||
* | Para 1 | 4k
|
||||
* +------------+
|
||||
* | Para 2 | 4k
|
||||
* +------------+ 0x0012000
|
||||
* |vectors |
|
||||
* | |
|
||||
* |------------+
|
||||
* |text |
|
||||
* |data | 632k
|
||||
* | |
|
||||
* +------------+
|
||||
*
|
||||
*
|
||||
* +------------+ 0x00B0000
|
||||
* | |
|
||||
* | |
|
||||
* | OTA TEMP |
|
||||
* | |
|
||||
* | |
|
||||
* | | 320k
|
||||
* +------------+
|
||||
*/
|
||||
|
||||
|
||||
/* Split memory into area for vectors and ram */
|
||||
MEMORY
|
||||
{
|
||||
flash (rx) : ORIGIN = 0x0012000, LENGTH = 546936
|
||||
ram (rwx): ORIGIN = 0x00400020, LENGTH = 256k - 32
|
||||
}
|
||||
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(_vector_start);
|
||||
_vector_start = 0x0012000;
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* vectors go to vectors region */
|
||||
. = 0x0012000;
|
||||
.vectors :
|
||||
{
|
||||
KEEP(*(*.vectors))
|
||||
} > flash
|
||||
|
||||
/* instructions go to the text region*/
|
||||
|
||||
. = ALIGN(0x8);
|
||||
/* code, instructions.for example: i=i+1; */
|
||||
.text :
|
||||
{
|
||||
*(.text*)
|
||||
KEEP(*(.init))
|
||||
KEEP(*(.fini))
|
||||
|
||||
/* .ctors */
|
||||
*crtbegin.o(.ctors)
|
||||
*crtbegin?.o(.ctors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
|
||||
*(SORT(.ctors.*))
|
||||
*(.ctors)
|
||||
|
||||
/* .dtors */
|
||||
*crtbegin.o(.dtors)
|
||||
*crtbegin?.o(.dtors)
|
||||
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
|
||||
*(SORT(.dtors.*))
|
||||
*(.dtors)
|
||||
|
||||
*(.rodata*)
|
||||
KEEP(*(.eh_frame*))
|
||||
|
||||
} > flash
|
||||
|
||||
.ARM.extab ALIGN(8) :
|
||||
{
|
||||
*(.ARM.extab* .gnu.linkonce.armextab.*)
|
||||
} > flash
|
||||
|
||||
.ARM.exidx ALIGN(8):
|
||||
{
|
||||
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
|
||||
} > flash
|
||||
|
||||
_begin_data = .;
|
||||
.data : AT ( _begin_data )
|
||||
{
|
||||
__data_start__ = .;
|
||||
_sdata = .;
|
||||
*(.data*)
|
||||
|
||||
. = ALIGN(4);
|
||||
/* preinit data */
|
||||
PROVIDE_HIDDEN (__preinit_array_start = .);
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN (__preinit_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* init data */
|
||||
PROVIDE_HIDDEN (__init_array_start = .);
|
||||
KEEP(*(SORT(.init_array.*)))
|
||||
KEEP(*(.init_array))
|
||||
PROVIDE_HIDDEN (__init_array_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
/* finit data */
|
||||
PROVIDE_HIDDEN (__fini_array_start = .);
|
||||
KEEP(*(SORT(.fini_array.*)))
|
||||
KEEP(*(.fini_array))
|
||||
PROVIDE_HIDDEN (__fini_array_end = .);
|
||||
|
||||
KEEP(*(.jcr*))
|
||||
SORT(CONSTRUCTORS)
|
||||
|
||||
/* All data end */
|
||||
__data_end__ = .;
|
||||
_edata = .;
|
||||
|
||||
KEEP(*(.dummydata))
|
||||
} >ram
|
||||
|
||||
/* Loader will copy data from _flash_begin to _ram_begin..ram_end */
|
||||
_data_flash_begin = LOADADDR(.data);
|
||||
_data_ram_begin = ADDR(.data);
|
||||
_data_ram_end = .;
|
||||
|
||||
/* uninitialized data section - global int i; */
|
||||
.bss ALIGN(8):
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_bss_start = .;
|
||||
__bss_start__ = .;
|
||||
_sbss = .;
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
_bss_end = .;
|
||||
__bss_end__ = .;
|
||||
_ebss = .;
|
||||
} > ram /* in RAM */
|
||||
|
||||
. = ALIGN (8);
|
||||
_empty_ram = .;
|
||||
|
||||
/* This symbol defines end of code/data sections. Heap starts here. */
|
||||
PROVIDE(end = .);
|
||||
PROVIDE(_heap_start = .);
|
||||
|
||||
.heap (COPY):
|
||||
{
|
||||
__end__ = .;
|
||||
end = __end__;
|
||||
*(.heap*)
|
||||
__HeapLimit = .;
|
||||
} > ram
|
||||
|
||||
.stack_dummy (COPY):
|
||||
{
|
||||
*(.stack*)
|
||||
} > ram
|
||||
|
||||
/* _stack symbol defines initial stack bottom addres. Stack grows to lower addresses.
|
||||
Typically you set this to be top of your RAM. Note: code never checks, if stack
|
||||
grows into heap area!
|
||||
*/
|
||||
PROVIDE(_stack_unused = 0x440000 - 0x3F0 - 0x7F0 - 0xFF0 - 0x3F0 - 0x10); /* 0x10*/
|
||||
PROVIDE(_stack_svc = 0x440000 - 0x3F0 - 0x7F0 - 0xFF0 - 0x3F0); /* 0x3F0*/
|
||||
PROVIDE(_stack_irq = 0x440000 - 0x3F0 - 0x7F0 - 0xFF0); /* 0xFF0*/
|
||||
PROVIDE(_stack_fiq = 0x440000 - 0x3F0 - 0x7F0); /* 0x7F0*/
|
||||
PROVIDE(_stack_sys = 0x440000 - 0x3F0); /* 0x3F0*/
|
||||
|
||||
PROVIDE(_heap_end = _stack_unused);
|
||||
PROVIDE(_heap_len = _heap_end - _heap_start);
|
||||
|
||||
ASSERT ((_heap_len > 0x19000 - 1 ), "Error: No room left for the heap") /*heap must bigger than 100k*/
|
||||
|
||||
__StackTop = ORIGIN(ram) + LENGTH(ram);
|
||||
_estack = __StackTop;
|
||||
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
|
||||
PROVIDE(__stack = __StackTop);
|
||||
|
||||
}
|
||||
GROUP(
|
||||
libstdc++.a
|
||||
libsupc++.a
|
||||
libgcc.a
|
||||
libg.a
|
||||
libc.a
|
||||
libm.a
|
||||
libnosys.a
|
||||
)
|
||||
@@ -1,133 +1,133 @@
|
||||
#
|
||||
# UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
# Copyright (c) 2016 MXCHIP Inc.
|
||||
#
|
||||
# The contents of this file may not be disclosed to third parties, copied or
|
||||
# duplicated in any form, in whole or in part, without the prior written
|
||||
# permission of MXCHIP Corporation.
|
||||
#
|
||||
|
||||
|
||||
NAME = MOC108
|
||||
|
||||
# Host architecture is ARM968E-S
|
||||
HOST_ARCH := ARM968E-S
|
||||
|
||||
# Host MCU alias for OpenOCD
|
||||
HOST_OPENOCD := MOC108
|
||||
|
||||
GLOBAL_INCLUDES := . \
|
||||
.. \
|
||||
../.. \
|
||||
../../include \
|
||||
../../$(TOOLCHAIN_NAME) \
|
||||
../../$(HOST_ARCH) \
|
||||
../../$(HOST_ARCH)/CMSIS \
|
||||
peripherals
|
||||
|
||||
# Global flags
|
||||
GLOBAL_CFLAGS += $$(CPU_CFLAGS) -fno-builtin-printf -Wno-implicit-function-declaration -Wno-int-conversion -Wno-unused-variable -Wno-unused-function
|
||||
GLOBAL_CXXFLAGS += $$(CPU_CXXFLAGS)
|
||||
GLOBAL_ASMFLAGS += $$(CPU_ASMFLAGS)
|
||||
GLOBAL_LDFLAGS += $$(CPU_LDFLAGS)
|
||||
|
||||
GLOBAL_DEFINES += CONFIG_MX108
|
||||
GLOBAL_DEFINES += configUSE_WATCHDOG_TICK=32000
|
||||
GLOBAL_DEFINES += configTOTAL_HEAP_SIZE=102400
|
||||
GLOBAL_DEFINES += configTIMER_TASK_STACK_DEPTH=750
|
||||
GLOBAL_DEFINES += configUSE_TICKLESS_IDLE=0
|
||||
GLOBAL_DEFINES += CONFIG_USE_LINKER_HEAP=1
|
||||
|
||||
ifeq ($(filter $(RTOS),NoRTOS),)
|
||||
GLOBAL_LDFLAGS += -Wl,-wrap,_malloc_r -Wl,-wrap,free -Wl,-wrap,realloc -Wl,-wrap,malloc -Wl,-wrap,calloc -Wl,-wrap,_free_r -Wl,-wrap,_realloc_r #-Wl,-wrap,printf -Wl,-wrap,sprintf
|
||||
endif
|
||||
|
||||
GLOBAL_LDFLAGS += -Wl,-wrap,printf
|
||||
|
||||
GLOBAL_LDFLAGS += -L ./platform/MCU/$(NAME)/$(TOOLCHAIN_NAME)
|
||||
GLOBAL_LDFLAGS += --specs=nosys.specs
|
||||
|
||||
# Components
|
||||
ifdef TEMP_COMMENT
|
||||
$(NAME)_COMPONENTS += $(TOOLCHAIN_NAME)
|
||||
endif
|
||||
|
||||
|
||||
ifdef TOOLCHAIN_NAME
|
||||
ifneq ($(wildcard $(CURDIR)peripherals.$(HOST_ARCH).$(TOOLCHAIN_NAME).release.a),)
|
||||
$(NAME)_PREBUILT_LIBRARY := peripherals.$(HOST_ARCH).$(TOOLCHAIN_NAME).release.a
|
||||
else
|
||||
# Build from source
|
||||
$(NAME)_COMPONENTS += MCU/MOC108/peripherals
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_IPV6),1)
|
||||
IPV6 := -IPV6
|
||||
else
|
||||
IPV6 :=
|
||||
endif
|
||||
ifeq ($(CONFIG_SOFTAP),1)
|
||||
SOFTAP := -SOFTAP
|
||||
else
|
||||
SOFTAP :=
|
||||
endif
|
||||
ifneq ($(wildcard $(CURDIR)MX108$(IPV6)$(SOFTAP).$(HOST_ARCH).$(TOOLCHAIN_NAME).release.a),)
|
||||
$(NAME)_PREBUILT_LIBRARY += MX108$(IPV6)$(SOFTAP).$(HOST_ARCH).$(TOOLCHAIN_NAME).release.a
|
||||
else
|
||||
# Build from source
|
||||
$(NAME)_COMPONENTS += MCU/MOC108/MX108
|
||||
endif
|
||||
endif
|
||||
|
||||
# Source files
|
||||
$(NAME)_SOURCES := platform_stub.c \
|
||||
../../$(HOST_ARCH)/platform_core.c \
|
||||
../mico_platform_common.c \
|
||||
platform_init.c
|
||||
|
||||
|
||||
# Extra build target in mico_standard_targets.mk, include bootloader, and copy output file to eclipse debug file (copy_output_for_eclipse)
|
||||
EXTRA_TARGET_MAKEFILES += ./mico-os/platform/MCU/MOC108/moc108_standard_targets.mk
|
||||
EXTRA_TARGET_MAKEFILES += ./mico-os/platform/MCU/MOC108/gen_crc_bin.mk
|
||||
|
||||
ifeq ($(APP),bootloader)
|
||||
####################################################################################
|
||||
# Building bootloader
|
||||
####################################################################################
|
||||
|
||||
DEFAULT_LINK_SCRIPT += $(TOOLCHAIN_NAME)/bootloader$(LINK_SCRIPT_SUFFIX)
|
||||
GLOBAL_INCLUDES +=
|
||||
|
||||
else
|
||||
ifneq ($(filter spi_flash_write, $(APP)),)
|
||||
####################################################################################
|
||||
# Building spi_flash_write
|
||||
####################################################################################
|
||||
|
||||
PRE_APP_BUILDS += bootloader
|
||||
DEFAULT_LINK_SCRIPT := $(TOOLCHAIN_NAME)/app_ram$(LINK_SCRIPT_SUFFIX)
|
||||
GLOBAL_DEFINES += __JTAG_FLASH_WRITER_DATA_BUFFER_SIZE__=16384
|
||||
GLOBAL_INCLUDES +=
|
||||
|
||||
else
|
||||
ifeq ($(USES_BOOTLOADER),1)
|
||||
####################################################################################
|
||||
# Building standard application to run with bootloader
|
||||
####################################################################################
|
||||
|
||||
PRE_APP_BUILDS += bootloader
|
||||
DEFAULT_LINK_SCRIPT := $(TOOLCHAIN_NAME)/app_with_bootloader$(LINK_SCRIPT_SUFFIX)
|
||||
GLOBAL_INCLUDES +=
|
||||
|
||||
else
|
||||
####################################################################################
|
||||
# Building a standalone application (standalone app without bootloader)
|
||||
####################################################################################
|
||||
|
||||
DEFAULT_LINK_SCRIPT := $(TOOLCHAIN_NAME)/app_no_bootloader$(LINK_SCRIPT_SUFFIX)
|
||||
GLOBAL_INCLUDES +=
|
||||
|
||||
endif # USES_BOOTLOADER = 1
|
||||
endif # APP=spi_flash_write
|
||||
endif # APP=bootloader
|
||||
|
||||
#
|
||||
# UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
# Copyright (c) 2016 MXCHIP Inc.
|
||||
#
|
||||
# The contents of this file may not be disclosed to third parties, copied or
|
||||
# duplicated in any form, in whole or in part, without the prior written
|
||||
# permission of MXCHIP Corporation.
|
||||
#
|
||||
|
||||
|
||||
NAME = MOC108
|
||||
|
||||
# Host architecture is ARM968E-S
|
||||
HOST_ARCH := ARM968E-S
|
||||
|
||||
# Host MCU alias for OpenOCD
|
||||
HOST_OPENOCD := MOC108
|
||||
|
||||
GLOBAL_INCLUDES := . \
|
||||
.. \
|
||||
../.. \
|
||||
../../include \
|
||||
../../$(TOOLCHAIN_NAME) \
|
||||
../../$(HOST_ARCH) \
|
||||
../../$(HOST_ARCH)/CMSIS \
|
||||
peripherals
|
||||
|
||||
# Global flags
|
||||
GLOBAL_CFLAGS += $$(CPU_CFLAGS) -fno-builtin-printf -Wno-implicit-function-declaration -Wno-int-conversion -Wno-unused-variable -Wno-unused-function
|
||||
GLOBAL_CXXFLAGS += $$(CPU_CXXFLAGS)
|
||||
GLOBAL_ASMFLAGS += $$(CPU_ASMFLAGS)
|
||||
GLOBAL_LDFLAGS += $$(CPU_LDFLAGS)
|
||||
|
||||
GLOBAL_DEFINES += CONFIG_MX108
|
||||
GLOBAL_DEFINES += configUSE_WATCHDOG_TICK=32000
|
||||
GLOBAL_DEFINES += configTOTAL_HEAP_SIZE=102400
|
||||
GLOBAL_DEFINES += configTIMER_TASK_STACK_DEPTH=750
|
||||
GLOBAL_DEFINES += configUSE_TICKLESS_IDLE=0
|
||||
GLOBAL_DEFINES += CONFIG_USE_LINKER_HEAP=1
|
||||
|
||||
ifeq ($(filter $(RTOS),NoRTOS),)
|
||||
GLOBAL_LDFLAGS += -Wl,-wrap,_malloc_r -Wl,-wrap,free -Wl,-wrap,realloc -Wl,-wrap,malloc -Wl,-wrap,calloc -Wl,-wrap,_free_r -Wl,-wrap,_realloc_r #-Wl,-wrap,printf -Wl,-wrap,sprintf
|
||||
endif
|
||||
|
||||
GLOBAL_LDFLAGS += -Wl,-wrap,printf
|
||||
|
||||
GLOBAL_LDFLAGS += -L ./platform/MCU/$(NAME)/$(TOOLCHAIN_NAME)
|
||||
GLOBAL_LDFLAGS += --specs=nosys.specs
|
||||
|
||||
# Components
|
||||
ifdef TEMP_COMMENT
|
||||
$(NAME)_COMPONENTS += $(TOOLCHAIN_NAME)
|
||||
endif
|
||||
|
||||
|
||||
ifdef TOOLCHAIN_NAME
|
||||
ifneq ($(wildcard $(CURDIR)peripherals.$(HOST_ARCH).$(TOOLCHAIN_NAME).release.a),)
|
||||
$(NAME)_PREBUILT_LIBRARY := peripherals.$(HOST_ARCH).$(TOOLCHAIN_NAME).release.a
|
||||
else
|
||||
# Build from source
|
||||
$(NAME)_COMPONENTS += MCU/MOC108/peripherals
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_IPV6),1)
|
||||
IPV6 := -IPV6
|
||||
else
|
||||
IPV6 :=
|
||||
endif
|
||||
ifeq ($(CONFIG_SOFTAP),1)
|
||||
SOFTAP := -SOFTAP
|
||||
else
|
||||
SOFTAP :=
|
||||
endif
|
||||
ifneq ($(wildcard $(CURDIR)MX108$(IPV6)$(SOFTAP).$(HOST_ARCH).$(TOOLCHAIN_NAME).release.a),)
|
||||
$(NAME)_PREBUILT_LIBRARY += MX108$(IPV6)$(SOFTAP).$(HOST_ARCH).$(TOOLCHAIN_NAME).release.a
|
||||
else
|
||||
# Build from source
|
||||
$(NAME)_COMPONENTS += MCU/MOC108/MX108
|
||||
endif
|
||||
endif
|
||||
|
||||
# Source files
|
||||
$(NAME)_SOURCES := platform_stub.c \
|
||||
../../$(HOST_ARCH)/platform_core.c \
|
||||
../mico_platform_common.c \
|
||||
platform_init.c
|
||||
|
||||
|
||||
# Extra build target in mico_standard_targets.mk, include bootloader, and copy output file to eclipse debug file (copy_output_for_eclipse)
|
||||
EXTRA_TARGET_MAKEFILES += ./mico-os/platform/MCU/MOC108/moc108_standard_targets.mk
|
||||
EXTRA_TARGET_MAKEFILES += ./mico-os/platform/MCU/MOC108/gen_crc_bin.mk
|
||||
|
||||
ifeq ($(APP),bootloader)
|
||||
####################################################################################
|
||||
# Building bootloader
|
||||
####################################################################################
|
||||
|
||||
DEFAULT_LINK_SCRIPT += $(TOOLCHAIN_NAME)/bootloader$(LINK_SCRIPT_SUFFIX)
|
||||
GLOBAL_INCLUDES +=
|
||||
|
||||
else
|
||||
ifneq ($(filter spi_flash_write, $(APP)),)
|
||||
####################################################################################
|
||||
# Building spi_flash_write
|
||||
####################################################################################
|
||||
|
||||
PRE_APP_BUILDS += bootloader
|
||||
DEFAULT_LINK_SCRIPT := $(TOOLCHAIN_NAME)/app_ram$(LINK_SCRIPT_SUFFIX)
|
||||
GLOBAL_DEFINES += __JTAG_FLASH_WRITER_DATA_BUFFER_SIZE__=16384
|
||||
GLOBAL_INCLUDES +=
|
||||
|
||||
else
|
||||
ifeq ($(USES_BOOTLOADER),1)
|
||||
####################################################################################
|
||||
# Building standard application to run with bootloader
|
||||
####################################################################################
|
||||
|
||||
PRE_APP_BUILDS += bootloader
|
||||
DEFAULT_LINK_SCRIPT := $(TOOLCHAIN_NAME)/app_with_bootloader$(LINK_SCRIPT_SUFFIX)
|
||||
GLOBAL_INCLUDES +=
|
||||
|
||||
else
|
||||
####################################################################################
|
||||
# Building a standalone application (standalone app without bootloader)
|
||||
####################################################################################
|
||||
|
||||
DEFAULT_LINK_SCRIPT := $(TOOLCHAIN_NAME)/app_no_bootloader$(LINK_SCRIPT_SUFFIX)
|
||||
GLOBAL_INCLUDES +=
|
||||
|
||||
endif # USES_BOOTLOADER = 1
|
||||
endif # APP=spi_flash_write
|
||||
endif # APP=bootloader
|
||||
|
||||
|
||||
@@ -1,184 +1,184 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file platform_init.c
|
||||
* @author William Xu
|
||||
* @version V1.0.0
|
||||
* @date 05-May-2014
|
||||
* @brief This file provide functions called by MICO to drive stm32f2xx
|
||||
* platform: - e.g. power save, reboot, platform initialize
|
||||
******************************************************************************
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include "platform_peripheral.h"
|
||||
#include "platform.h"
|
||||
#include "platform_config.h"
|
||||
#include "platform_logging.h"
|
||||
#include <string.h> // For memcmp
|
||||
#include "crt0.h"
|
||||
#include "mico_rtos.h"
|
||||
#include "platform_init.h"
|
||||
|
||||
#include "portmacro.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include "../../GCC/stdio_newlib.h"
|
||||
#endif /* ifdef __GNUC__ */
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
#ifndef STDIO_BUFFER_SIZE
|
||||
#define STDIO_BUFFER_SIZE 1024
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
extern OSStatus host_platform_init( void );
|
||||
extern void system_reload(void);
|
||||
/******************************************************
|
||||
* Variables Definitions
|
||||
******************************************************/
|
||||
extern platform_uart_t platform_uart_peripherals[];
|
||||
extern platform_uart_driver_t platform_uart_drivers[];
|
||||
|
||||
#ifndef MICO_DISABLE_STDIO
|
||||
static const platform_uart_config_t stdio_uart_config =
|
||||
{
|
||||
.baud_rate = STDIO_UART_BAUDRATE,
|
||||
.data_width = DATA_WIDTH_8BIT,
|
||||
.parity = NO_PARITY,
|
||||
.stop_bits = STOP_BITS_1,
|
||||
.flow_control = FLOW_CONTROL_DISABLED,
|
||||
.flags = 0,
|
||||
};
|
||||
|
||||
static volatile ring_buffer_t stdio_rx_buffer;
|
||||
static volatile uint8_t stdio_rx_data[STDIO_BUFFER_SIZE];
|
||||
mico_mutex_t stdio_rx_mutex;
|
||||
mico_mutex_t stdio_tx_mutex;
|
||||
#endif /* #ifndef MICO_DISABLE_STDIO */
|
||||
|
||||
/******************************************************
|
||||
* Function Definitions
|
||||
******************************************************/
|
||||
|
||||
|
||||
void __jump_to( uint32_t addr )
|
||||
{
|
||||
// addr |= 0x00000001; /* Last bit of jump address indicates whether destination is Thumb or ARM code */
|
||||
__asm volatile ("BX %0" : : "r" (addr) );
|
||||
}
|
||||
|
||||
|
||||
void startApplication( uint32_t app_addr )
|
||||
{
|
||||
intc_deinit();
|
||||
DISABLE_INTERRUPTS();
|
||||
__jump_to( app_addr );
|
||||
}
|
||||
|
||||
void platform_mcu_reset( void )
|
||||
{
|
||||
bk_wdg_initialize(1);
|
||||
}
|
||||
|
||||
/* STM32F2 common clock initialisation function
|
||||
* This brings up enough clocks to allow the processor to run quickly while initialising memory.
|
||||
* Other platform specific clock init can be done in init_platform() or init_architecture()
|
||||
*/
|
||||
void init_clocks( void )
|
||||
{
|
||||
#ifdef NO_MICO_RTOS
|
||||
fclk_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
WEAK void init_memory( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void init_architecture( void )
|
||||
{
|
||||
}
|
||||
|
||||
extern void entry_main(void);
|
||||
|
||||
/* mico_main is executed after rtos is start up and before real main*/
|
||||
void mico_main( void )
|
||||
{
|
||||
/* Customized board configuration. */
|
||||
init_platform( );
|
||||
|
||||
#ifndef MICO_DISABLE_STDIO
|
||||
if( stdio_tx_mutex == NULL )
|
||||
mico_rtos_init_mutex( &stdio_tx_mutex );
|
||||
|
||||
ring_buffer_init ( (ring_buffer_t*)&stdio_rx_buffer, (uint8_t*)stdio_rx_data, STDIO_BUFFER_SIZE );
|
||||
platform_uart_init( &platform_uart_drivers[STDIO_UART], &platform_uart_peripherals[STDIO_UART], &stdio_uart_config, (ring_buffer_t*)&stdio_rx_buffer );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void software_init_hook(void)
|
||||
{
|
||||
entry_main();
|
||||
main();
|
||||
}
|
||||
|
||||
OSStatus stdio_hardfault( char* data, uint32_t size )
|
||||
{
|
||||
return kNoErr;
|
||||
}
|
||||
|
||||
static char global_cid[25] = { 0 };
|
||||
const char *mico_generate_cid( uint8_t* length )
|
||||
{
|
||||
return global_cid;
|
||||
}
|
||||
|
||||
bool isWakeUpFlagPowerOn(void){
|
||||
return false;
|
||||
};
|
||||
|
||||
/******************************************************
|
||||
* NO-OS Functions
|
||||
******************************************************/
|
||||
|
||||
#ifdef NO_MICO_RTOS
|
||||
|
||||
uint32_t mico_get_time_no_os(void)
|
||||
{
|
||||
return fclk_get_tick();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file platform_init.c
|
||||
* @author William Xu
|
||||
* @version V1.0.0
|
||||
* @date 05-May-2014
|
||||
* @brief This file provide functions called by MICO to drive stm32f2xx
|
||||
* platform: - e.g. power save, reboot, platform initialize
|
||||
******************************************************************************
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include "platform_peripheral.h"
|
||||
#include "platform.h"
|
||||
#include "platform_config.h"
|
||||
#include "platform_logging.h"
|
||||
#include <string.h> // For memcmp
|
||||
#include "crt0.h"
|
||||
#include "mico_rtos.h"
|
||||
#include "platform_init.h"
|
||||
|
||||
#include "portmacro.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include "../../GCC/stdio_newlib.h"
|
||||
#endif /* ifdef __GNUC__ */
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
#ifndef STDIO_BUFFER_SIZE
|
||||
#define STDIO_BUFFER_SIZE 1024
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
extern OSStatus host_platform_init( void );
|
||||
extern void system_reload(void);
|
||||
/******************************************************
|
||||
* Variables Definitions
|
||||
******************************************************/
|
||||
extern platform_uart_t platform_uart_peripherals[];
|
||||
extern platform_uart_driver_t platform_uart_drivers[];
|
||||
|
||||
#ifndef MICO_DISABLE_STDIO
|
||||
static const platform_uart_config_t stdio_uart_config =
|
||||
{
|
||||
.baud_rate = STDIO_UART_BAUDRATE,
|
||||
.data_width = DATA_WIDTH_8BIT,
|
||||
.parity = NO_PARITY,
|
||||
.stop_bits = STOP_BITS_1,
|
||||
.flow_control = FLOW_CONTROL_DISABLED,
|
||||
.flags = 0,
|
||||
};
|
||||
|
||||
static volatile ring_buffer_t stdio_rx_buffer;
|
||||
static volatile uint8_t stdio_rx_data[STDIO_BUFFER_SIZE];
|
||||
mico_mutex_t stdio_rx_mutex;
|
||||
mico_mutex_t stdio_tx_mutex;
|
||||
#endif /* #ifndef MICO_DISABLE_STDIO */
|
||||
|
||||
/******************************************************
|
||||
* Function Definitions
|
||||
******************************************************/
|
||||
|
||||
|
||||
void __jump_to( uint32_t addr )
|
||||
{
|
||||
// addr |= 0x00000001; /* Last bit of jump address indicates whether destination is Thumb or ARM code */
|
||||
__asm volatile ("BX %0" : : "r" (addr) );
|
||||
}
|
||||
|
||||
|
||||
void startApplication( uint32_t app_addr )
|
||||
{
|
||||
intc_deinit();
|
||||
DISABLE_INTERRUPTS();
|
||||
__jump_to( app_addr );
|
||||
}
|
||||
|
||||
void platform_mcu_reset( void )
|
||||
{
|
||||
bk_wdg_initialize(1);
|
||||
}
|
||||
|
||||
/* STM32F2 common clock initialisation function
|
||||
* This brings up enough clocks to allow the processor to run quickly while initialising memory.
|
||||
* Other platform specific clock init can be done in init_platform() or init_architecture()
|
||||
*/
|
||||
void init_clocks( void )
|
||||
{
|
||||
#ifdef NO_MICO_RTOS
|
||||
fclk_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
WEAK void init_memory( void )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void init_architecture( void )
|
||||
{
|
||||
}
|
||||
|
||||
extern void entry_main(void);
|
||||
|
||||
/* mico_main is executed after rtos is start up and before real main*/
|
||||
void mico_main( void )
|
||||
{
|
||||
/* Customized board configuration. */
|
||||
init_platform( );
|
||||
|
||||
#ifndef MICO_DISABLE_STDIO
|
||||
if( stdio_tx_mutex == NULL )
|
||||
mico_rtos_init_mutex( &stdio_tx_mutex );
|
||||
|
||||
ring_buffer_init ( (ring_buffer_t*)&stdio_rx_buffer, (uint8_t*)stdio_rx_data, STDIO_BUFFER_SIZE );
|
||||
platform_uart_init( &platform_uart_drivers[STDIO_UART], &platform_uart_peripherals[STDIO_UART], &stdio_uart_config, (ring_buffer_t*)&stdio_rx_buffer );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void software_init_hook(void)
|
||||
{
|
||||
entry_main();
|
||||
main();
|
||||
}
|
||||
|
||||
OSStatus stdio_hardfault( char* data, uint32_t size )
|
||||
{
|
||||
return kNoErr;
|
||||
}
|
||||
|
||||
static char global_cid[25] = { 0 };
|
||||
const char *mico_generate_cid( uint8_t* length )
|
||||
{
|
||||
return global_cid;
|
||||
}
|
||||
|
||||
bool isWakeUpFlagPowerOn(void){
|
||||
return false;
|
||||
};
|
||||
|
||||
/******************************************************
|
||||
* NO-OS Functions
|
||||
******************************************************/
|
||||
|
||||
#ifdef NO_MICO_RTOS
|
||||
|
||||
uint32_t mico_get_time_no_os(void)
|
||||
{
|
||||
return fclk_get_tick();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,142 +1,142 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file platform_mcu_peripheral.h
|
||||
* @author William Xu
|
||||
* @version V1.0.0
|
||||
* @date 05-May-2014
|
||||
* @brief This file provide all the headers of functions for stm32f2xx platform
|
||||
******************************************************************************
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mico_rtos.h"
|
||||
#include "RingBufferUtils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
typedef enum
|
||||
{
|
||||
MX_UART_1,
|
||||
MX_UART_2,
|
||||
MX_UART_MAX, /* Denotes the total number of UART port aliases. Not a valid UART alias */
|
||||
MX_UART_NONE,
|
||||
} mx_uart_t;
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t pin; //GPIO_INDEX
|
||||
} platform_gpio_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unimplemented;
|
||||
} platform_adc_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unimplemented;
|
||||
} platform_pwm_t;
|
||||
|
||||
/* DMA can be enabled by setting SPI_USE_DMA */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unimplemented;
|
||||
} platform_spi_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
platform_spi_t* peripheral;
|
||||
mico_mutex_t spi_mutex;
|
||||
} platform_spi_driver_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unimplemented;
|
||||
} platform_spi_slave_driver_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const platform_gpio_t* pin_scl;
|
||||
const platform_gpio_t* pin_sda;
|
||||
} platform_i2c_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mico_mutex_t i2c_mutex;
|
||||
} platform_i2c_driver_t;
|
||||
|
||||
typedef void (* wakeup_irq_handler_t)(void *arg);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mx_uart_t port;
|
||||
} platform_uart_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
platform_uart_t* peripheral;
|
||||
ring_buffer_t* rx_buffer;
|
||||
mico_semaphore_t rx_complete;
|
||||
mico_semaphore_t tx_complete;
|
||||
mico_mutex_t tx_mutex;
|
||||
mico_semaphore_t sem_wakeup;
|
||||
volatile uint32_t tx_size;
|
||||
volatile uint32_t rx_size;
|
||||
volatile OSStatus last_receive_result;
|
||||
volatile OSStatus last_transmit_result;
|
||||
// volatile bool initialized;
|
||||
} platform_uart_driver_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t flash_type;
|
||||
uint32_t flash_start_addr;
|
||||
uint32_t flash_length;
|
||||
uint32_t flash_protect_opt;
|
||||
} platform_flash_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const platform_flash_t* peripheral;
|
||||
mico_mutex_t flash_mutex;
|
||||
volatile bool initialized;
|
||||
} platform_flash_driver_t;
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file platform_mcu_peripheral.h
|
||||
* @author William Xu
|
||||
* @version V1.0.0
|
||||
* @date 05-May-2014
|
||||
* @brief This file provide all the headers of functions for stm32f2xx platform
|
||||
******************************************************************************
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mico_rtos.h"
|
||||
#include "RingBufferUtils.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
typedef enum
|
||||
{
|
||||
MX_UART_1,
|
||||
MX_UART_2,
|
||||
MX_UART_MAX, /* Denotes the total number of UART port aliases. Not a valid UART alias */
|
||||
MX_UART_NONE,
|
||||
} mx_uart_t;
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t pin; //GPIO_INDEX
|
||||
} platform_gpio_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unimplemented;
|
||||
} platform_adc_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unimplemented;
|
||||
} platform_pwm_t;
|
||||
|
||||
/* DMA can be enabled by setting SPI_USE_DMA */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unimplemented;
|
||||
} platform_spi_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
platform_spi_t* peripheral;
|
||||
mico_mutex_t spi_mutex;
|
||||
} platform_spi_driver_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unimplemented;
|
||||
} platform_spi_slave_driver_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const platform_gpio_t* pin_scl;
|
||||
const platform_gpio_t* pin_sda;
|
||||
} platform_i2c_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mico_mutex_t i2c_mutex;
|
||||
} platform_i2c_driver_t;
|
||||
|
||||
typedef void (* wakeup_irq_handler_t)(void *arg);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mx_uart_t port;
|
||||
} platform_uart_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
platform_uart_t* peripheral;
|
||||
ring_buffer_t* rx_buffer;
|
||||
mico_semaphore_t rx_complete;
|
||||
mico_semaphore_t tx_complete;
|
||||
mico_mutex_t tx_mutex;
|
||||
mico_semaphore_t sem_wakeup;
|
||||
volatile uint32_t tx_size;
|
||||
volatile uint32_t rx_size;
|
||||
volatile OSStatus last_receive_result;
|
||||
volatile OSStatus last_transmit_result;
|
||||
// volatile bool initialized;
|
||||
} platform_uart_driver_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t flash_type;
|
||||
uint32_t flash_start_addr;
|
||||
uint32_t flash_length;
|
||||
uint32_t flash_protect_opt;
|
||||
} platform_flash_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const platform_flash_t* peripheral;
|
||||
mico_mutex_t flash_mutex;
|
||||
volatile bool initialized;
|
||||
} platform_flash_driver_t;
|
||||
|
||||
/******************************************************
|
||||
* Global Variables
|
||||
******************************************************/
|
||||
|
||||
|
||||
/******************************************************
|
||||
* Function Declarations
|
||||
******************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,127 +1,127 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file platform_init.c
|
||||
* @author William Xu
|
||||
* @version V1.0.0
|
||||
* @date 05-May-2014
|
||||
* @brief This file provide functions called by MICO to drive stm32f2xx
|
||||
* platform: - e.g. power save, reboot, platform initialize
|
||||
******************************************************************************
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/times.h>
|
||||
#include <sys/unistd.h>
|
||||
#include "stdio_newlib.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
#ifndef EBADF
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
/************** wrap C library functions **************/
|
||||
void * __wrap_malloc (size_t size)
|
||||
{
|
||||
return pvPortMalloc(size);
|
||||
}
|
||||
|
||||
void * __wrap__malloc_r (void *p, size_t size)
|
||||
{
|
||||
|
||||
return pvPortMalloc(size);
|
||||
}
|
||||
|
||||
void __wrap_free (void *pv)
|
||||
{
|
||||
vPortFree(pv);
|
||||
}
|
||||
|
||||
void * __wrap_calloc (size_t a, size_t b)
|
||||
{
|
||||
void *pvReturn;
|
||||
|
||||
pvReturn = pvPortMalloc( a*b );
|
||||
if (pvReturn)
|
||||
{
|
||||
memset(pvReturn, 0, a*b);
|
||||
}
|
||||
|
||||
return pvReturn;
|
||||
}
|
||||
|
||||
void * __wrap_realloc (void* pv, size_t size)
|
||||
{
|
||||
return pvPortRealloc(pv, size);
|
||||
}
|
||||
|
||||
void __wrap__free_r (void *p, void *x)
|
||||
{
|
||||
__wrap_free(x);
|
||||
}
|
||||
|
||||
void* __wrap__realloc_r (void *p, void* x, size_t sz)
|
||||
{
|
||||
return __wrap_realloc (x, sz);
|
||||
}
|
||||
|
||||
int __wrap_printf (const char* format, ...)
|
||||
{
|
||||
int size;
|
||||
va_list ap;
|
||||
static char print_buf[1024];
|
||||
|
||||
va_start(ap, format);
|
||||
size = vsnprintf(print_buf, sizeof(print_buf) - 1, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
MicoUartSend(STDIO_UART, print_buf, size);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
int _gettimeofday( struct timeval * __p, void * __tz )
|
||||
{
|
||||
mico_utc_time_ms_t current_utc_time_ms = 0;
|
||||
uint64_t current_time_ns;
|
||||
mico_time_get_utc_time_ms( ¤t_utc_time_ms );
|
||||
|
||||
current_time_ns = mico_nanosecond_clock_value();
|
||||
__p->tv_sec = current_utc_time_ms / 1000;
|
||||
__p->tv_usec = ( current_utc_time_ms % 1000 ) * 1000 + ( current_time_ns / 1000 ) % 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gettimeofday( struct timeval *__restrict __p, void *__restrict __tz )
|
||||
{
|
||||
return _gettimeofday( __p, __tz );
|
||||
}
|
||||
|
||||
|
||||
time_t time(time_t *tloc)
|
||||
{
|
||||
mico_utc_time_ms_t current_utc_time_ms = 0;
|
||||
unsigned long long t;
|
||||
|
||||
mico_time_get_utc_time_ms( ¤t_utc_time_ms );
|
||||
|
||||
t = current_utc_time_ms / 1000;
|
||||
|
||||
if (tloc)
|
||||
*tloc = t ;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file platform_init.c
|
||||
* @author William Xu
|
||||
* @version V1.0.0
|
||||
* @date 05-May-2014
|
||||
* @brief This file provide functions called by MICO to drive stm32f2xx
|
||||
* platform: - e.g. power save, reboot, platform initialize
|
||||
******************************************************************************
|
||||
* UNPUBLISHED PROPRIETARY SOURCE CODE
|
||||
* Copyright (c) 2016 MXCHIP Inc.
|
||||
*
|
||||
* The contents of this file may not be disclosed to third parties, copied or
|
||||
* duplicated in any form, in whole or in part, without the prior written
|
||||
* permission of MXCHIP Corporation.
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/times.h>
|
||||
#include <sys/unistd.h>
|
||||
#include "stdio_newlib.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#undef errno
|
||||
extern int errno;
|
||||
|
||||
#ifndef EBADF
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
/************** wrap C library functions **************/
|
||||
void * __wrap_malloc (size_t size)
|
||||
{
|
||||
return pvPortMalloc(size);
|
||||
}
|
||||
|
||||
void * __wrap__malloc_r (void *p, size_t size)
|
||||
{
|
||||
|
||||
return pvPortMalloc(size);
|
||||
}
|
||||
|
||||
void __wrap_free (void *pv)
|
||||
{
|
||||
vPortFree(pv);
|
||||
}
|
||||
|
||||
void * __wrap_calloc (size_t a, size_t b)
|
||||
{
|
||||
void *pvReturn;
|
||||
|
||||
pvReturn = pvPortMalloc( a*b );
|
||||
if (pvReturn)
|
||||
{
|
||||
memset(pvReturn, 0, a*b);
|
||||
}
|
||||
|
||||
return pvReturn;
|
||||
}
|
||||
|
||||
void * __wrap_realloc (void* pv, size_t size)
|
||||
{
|
||||
return pvPortRealloc(pv, size);
|
||||
}
|
||||
|
||||
void __wrap__free_r (void *p, void *x)
|
||||
{
|
||||
__wrap_free(x);
|
||||
}
|
||||
|
||||
void* __wrap__realloc_r (void *p, void* x, size_t sz)
|
||||
{
|
||||
return __wrap_realloc (x, sz);
|
||||
}
|
||||
|
||||
int __wrap_printf (const char* format, ...)
|
||||
{
|
||||
int size;
|
||||
va_list ap;
|
||||
static char print_buf[1024];
|
||||
|
||||
va_start(ap, format);
|
||||
size = vsnprintf(print_buf, sizeof(print_buf) - 1, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
MicoUartSend(STDIO_UART, print_buf, size);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
int _gettimeofday( struct timeval * __p, void * __tz )
|
||||
{
|
||||
mico_utc_time_ms_t current_utc_time_ms = 0;
|
||||
uint64_t current_time_ns;
|
||||
mico_time_get_utc_time_ms( ¤t_utc_time_ms );
|
||||
|
||||
current_time_ns = mico_nanosecond_clock_value();
|
||||
__p->tv_sec = current_utc_time_ms / 1000;
|
||||
__p->tv_usec = ( current_utc_time_ms % 1000 ) * 1000 + ( current_time_ns / 1000 ) % 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gettimeofday( struct timeval *__restrict __p, void *__restrict __tz )
|
||||
{
|
||||
return _gettimeofday( __p, __tz );
|
||||
}
|
||||
|
||||
|
||||
time_t time(time_t *tloc)
|
||||
{
|
||||
mico_utc_time_ms_t current_utc_time_ms = 0;
|
||||
unsigned long long t;
|
||||
|
||||
mico_time_get_utc_time_ms( ¤t_utc_time_ms );
|
||||
|
||||
t = current_utc_time_ms / 1000;
|
||||
|
||||
if (tloc)
|
||||
*tloc = t ;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user