mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-17 15:38:14 +08:00
修复mico-sdk错误
This commit is contained in:
@@ -1,141 +1,141 @@
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
ENTRY( moc_app_main );
|
||||
|
||||
|
||||
MEMORY
|
||||
{
|
||||
APP_FLASH (rx) : ORIGIN = 0x08088000, LENGTH = 256K
|
||||
SRAM (rwx) : ORIGIN = 0x10030000, LENGTH = 56K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.vectors :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
|
||||
KEEP(*(*.user_handler))
|
||||
|
||||
. = ALIGN(., 4);
|
||||
}>APP_FLASH AT> APP_FLASH
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
|
||||
link_code_location = .;
|
||||
KEEP(*(.text.irq ))
|
||||
*(.text .text.* .gnu.linkonce.t.*)
|
||||
link_code_end = .;
|
||||
|
||||
. = ALIGN(0x4);
|
||||
|
||||
link_const_variable_data_location = .;
|
||||
*(.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);
|
||||
|
||||
}>APP_FLASH AT> APP_FLASH
|
||||
|
||||
/*
|
||||
* The .ARM.exidx and .ARM.extab 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 = .;
|
||||
} > APP_FLASH AT> APP_FLASH
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
__extab_start = ALIGN(4);
|
||||
*(.ARM.extab*)
|
||||
__extab_end = .;
|
||||
} > APP_FLASH AT> APP_FLASH
|
||||
|
||||
.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> APP_FLASH
|
||||
|
||||
.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> APP_FLASH
|
||||
|
||||
|
||||
.bss : /* Zero initialised memory used for zero initialised variables */
|
||||
{
|
||||
link_bss_location = ALIGN(., 4);
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
link_bss_end = .;
|
||||
. = ALIGN(., 4);
|
||||
}> 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*)
|
||||
}
|
||||
_ram_end_ = ORIGIN(SRAM) + LENGTH(SRAM);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
ENTRY( moc_app_main );
|
||||
|
||||
|
||||
MEMORY
|
||||
{
|
||||
APP_FLASH (rx) : ORIGIN = 0x08088000, LENGTH = 256K
|
||||
SRAM (rwx) : ORIGIN = 0x10030000, LENGTH = 56K
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.vectors :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
|
||||
KEEP(*(*.user_handler))
|
||||
|
||||
. = ALIGN(., 4);
|
||||
}>APP_FLASH AT> APP_FLASH
|
||||
|
||||
.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
|
||||
link_code_location = .;
|
||||
KEEP(*(.text.irq ))
|
||||
*(.text .text.* .gnu.linkonce.t.*)
|
||||
link_code_end = .;
|
||||
|
||||
. = ALIGN(0x4);
|
||||
|
||||
link_const_variable_data_location = .;
|
||||
*(.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);
|
||||
|
||||
}>APP_FLASH AT> APP_FLASH
|
||||
|
||||
/*
|
||||
* The .ARM.exidx and .ARM.extab 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 = .;
|
||||
} > APP_FLASH AT> APP_FLASH
|
||||
|
||||
.ARM.extab :
|
||||
{
|
||||
__extab_start = ALIGN(4);
|
||||
*(.ARM.extab*)
|
||||
__extab_end = .;
|
||||
} > APP_FLASH AT> APP_FLASH
|
||||
|
||||
.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> APP_FLASH
|
||||
|
||||
.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> APP_FLASH
|
||||
|
||||
|
||||
.bss : /* Zero initialised memory used for zero initialised variables */
|
||||
{
|
||||
link_bss_location = ALIGN(., 4);
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
link_bss_end = .;
|
||||
. = ALIGN(., 4);
|
||||
}> 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*)
|
||||
}
|
||||
_ram_end_ = ORIGIN(SRAM) + LENGTH(SRAM);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,118 +1,114 @@
|
||||
#
|
||||
# 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 = MX1290
|
||||
|
||||
# Host architecture is ARM Cortex M4
|
||||
HOST_ARCH := Cortex-M4F
|
||||
HOST_ARCH_M4 = Cortex-M4
|
||||
# Host MCU alias for OpenOCD
|
||||
HOST_OPENOCD := MX1290
|
||||
|
||||
GLOBAL_DEFINES += __FPU_PRESENT CONFIG_CPU_MX1290
|
||||
|
||||
# Global flags
|
||||
GLOBAL_CFLAGS += $$(CPU_CFLAGS) $$(ENDIAN_CFLAGS_LITTLE)
|
||||
GLOBAL_CXXFLAGS += $$(CPU_CXXFLAGS) $$(ENDIAN_CXXFLAGS_LITTLE)
|
||||
GLOBAL_ASMFLAGS += $$(CPU_ASMFLAGS) $$(ENDIAN_ASMFLAGS_LITTLE)
|
||||
GLOBAL_LDFLAGS += $$(CPU_LDFLAGS) $$(ENDIAN_LDFLAGS_LITTLE)
|
||||
|
||||
|
||||
GLOBAL_LDFLAGS += -nostartfiles
|
||||
GLOBAL_LDFLAGS += -Wl,--defsym,__STACKSIZE__=$$($(RTOS)_START_STACK)
|
||||
GLOBAL_LDFLAGS += -L ./platform/MCU/$(NAME)/$(TOOLCHAIN_NAME)
|
||||
|
||||
# Components
|
||||
$(NAME)_COMPONENTS += $(TOOLCHAIN_NAME)
|
||||
|
||||
GLOBAL_INCLUDES := . \
|
||||
.. \
|
||||
../.. \
|
||||
../../include \
|
||||
../../$(TOOLCHAIN_NAME) \
|
||||
../../$(HOST_ARCH_M4) \
|
||||
../../$(HOST_ARCH_M4)/CMSIS \
|
||||
interface \
|
||||
peripherals
|
||||
|
||||
$(NAME)_SOURCES := ../../$(HOST_ARCH_M4)/crt0_$(TOOLCHAIN_NAME).c \
|
||||
../../$(HOST_ARCH_M4)/platform_core.c \
|
||||
../platform_nsclock.c
|
||||
|
||||
$(NAME)_CFLAGS += -Wno-implicit-function-declaration -Wno-unused-variable
|
||||
|
||||
# These need to be forced into the final ELF since they are not referenced otherwise
|
||||
$(NAME)_LINK_FILES := ../../$(HOST_ARCH_M4)/crt0_$(TOOLCHAIN_NAME).o
|
||||
|
||||
ifneq ($(filter $(subst ., ,$(COMPONENTS)),mocOS),)
|
||||
####################################################################################
|
||||
# MOC application
|
||||
####################################################################################
|
||||
$(NAME)_SOURCES += ../moc_platform_common.c
|
||||
$(NAME)_SOURCES += moc/moc_adapter.c
|
||||
else
|
||||
####################################################################################
|
||||
# Building stand-alone image( sub build: spi_flash_write )
|
||||
####################################################################################
|
||||
$(NAME)_SOURCES += platform_vector_table.c \
|
||||
GCC/platform_unhandled_isr.c \
|
||||
../../$(HOST_ARCH_M4)/hardfault_handler.c \
|
||||
../mico_platform_common.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_pmu.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_pinmux.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_driver.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_clock.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_flash.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_flashc.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_qspi.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_uart.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_crc.c \
|
||||
peripherals/sdk/src/drivers/mw300/mdev_iflash.c \
|
||||
peripherals/sdk/src/drivers/common/mdev_crc.c \
|
||||
peripherals/sdk/src/core/util/crc/crc32.c \
|
||||
peripherals/sdk/src/core/util/arc4.c \
|
||||
peripherals/sdk/src/core/partition/partition.c \
|
||||
peripherals/sdk/src/core/mdev/mdev.c \
|
||||
peripherals/sdk/src/core/util/flash.c \
|
||||
peripherals/sdk/src/core/util/boot_flags.c \
|
||||
peripherals/boot2/boot2.c \
|
||||
peripherals/boot2/utils/crc32.c \
|
||||
peripherals/platform_uart.c \
|
||||
peripherals/platform_flash.c \
|
||||
platform_init.c
|
||||
|
||||
GLOBAL_INCLUDES += peripherals/boot2
|
||||
|
||||
GLOBAL_DEFINES += CONFIG_FLASH_PARTITION_COUNT=10 \
|
||||
ARM_GNU
|
||||
|
||||
$(NAME)_LINK_FILES += ../../$(HOST_ARCH_M4)/hardfault_handler.o \
|
||||
platform_vector_table.o
|
||||
endif
|
||||
|
||||
ifneq ($(filter spi_flash_write, $(APP)),)
|
||||
####################################################################################
|
||||
# Building spi_flash_write
|
||||
####################################################################################
|
||||
|
||||
DEFAULT_LINK_SCRIPT := $(TOOLCHAIN_NAME)/app_ram$(LINK_SCRIPT_SUFFIX)
|
||||
GLOBAL_DEFINES += __JTAG_FLASH_WRITER_DATA_BUFFER_SIZE__=16384
|
||||
|
||||
else
|
||||
ifneq ($(filter $(subst ., ,$(COMPONENTS)),mocOS),)
|
||||
####################################################################################
|
||||
# Building standard moc application
|
||||
####################################################################################
|
||||
|
||||
DEFAULT_LINK_SCRIPT := $(TOOLCHAIN_NAME)/app_with_moc$(LINK_SCRIPT_SUFFIX)
|
||||
|
||||
endif # APP=moc
|
||||
endif # APP=spi_flash_write
|
||||
|
||||
#
|
||||
# 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 = MX1290
|
||||
|
||||
# Host architecture is ARM Cortex M4
|
||||
HOST_ARCH := Cortex-M4F
|
||||
HOST_ARCH_M4 = Cortex-M4
|
||||
# Host MCU alias for OpenOCD
|
||||
HOST_OPENOCD := MX1290
|
||||
|
||||
GLOBAL_DEFINES += __FPU_PRESENT CONFIG_CPU_MX1290
|
||||
|
||||
# Global flags
|
||||
GLOBAL_CFLAGS += $$(CPU_CFLAGS) $$(ENDIAN_CFLAGS_LITTLE)
|
||||
GLOBAL_CXXFLAGS += $$(CPU_CXXFLAGS) $$(ENDIAN_CXXFLAGS_LITTLE)
|
||||
GLOBAL_ASMFLAGS += $$(CPU_ASMFLAGS) $$(ENDIAN_ASMFLAGS_LITTLE)
|
||||
GLOBAL_LDFLAGS += $$(CPU_LDFLAGS) $$(ENDIAN_LDFLAGS_LITTLE)
|
||||
|
||||
|
||||
GLOBAL_LDFLAGS += -nostartfiles
|
||||
GLOBAL_LDFLAGS += -Wl,--defsym,__STACKSIZE__=$$($(RTOS)_START_STACK)
|
||||
GLOBAL_LDFLAGS += -L ./platform/MCU/$(NAME)/$(TOOLCHAIN_NAME)
|
||||
|
||||
# Components
|
||||
$(NAME)_COMPONENTS += $(TOOLCHAIN_NAME)
|
||||
|
||||
GLOBAL_INCLUDES := . \
|
||||
.. \
|
||||
../.. \
|
||||
../../include \
|
||||
../../$(TOOLCHAIN_NAME) \
|
||||
../../$(HOST_ARCH_M4) \
|
||||
../../$(HOST_ARCH_M4)/CMSIS \
|
||||
interface \
|
||||
peripherals
|
||||
|
||||
$(NAME)_SOURCES := ../../$(HOST_ARCH_M4)/crt0_$(TOOLCHAIN_NAME).c \
|
||||
../../$(HOST_ARCH_M4)/platform_core.c \
|
||||
../platform_nsclock.c
|
||||
|
||||
$(NAME)_CFLAGS += -Wno-implicit-function-declaration -Wno-unused-variable
|
||||
|
||||
|
||||
ifneq ($(filter $(subst ., ,$(COMPONENTS)),mocOS),)
|
||||
####################################################################################
|
||||
# MOC application
|
||||
####################################################################################
|
||||
$(NAME)_SOURCES += ../moc_platform_common.c
|
||||
$(NAME)_SOURCES += moc/moc_adapter.c
|
||||
else
|
||||
####################################################################################
|
||||
# Building stand-alone image( sub build: spi_flash_write )
|
||||
####################################################################################
|
||||
$(NAME)_SOURCES += platform_vector_table.c \
|
||||
GCC/platform_unhandled_isr.c \
|
||||
../../$(HOST_ARCH_M4)/hardfault_handler.c \
|
||||
../mico_platform_common.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_pmu.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_pinmux.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_driver.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_clock.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_flash.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_flashc.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_qspi.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_uart.c \
|
||||
peripherals/sdk/src/drivers/mw300/lowlevel/mw300_crc.c \
|
||||
peripherals/sdk/src/drivers/mw300/mdev_iflash.c \
|
||||
peripherals/sdk/src/drivers/common/mdev_crc.c \
|
||||
peripherals/sdk/src/core/util/crc/crc32.c \
|
||||
peripherals/sdk/src/core/util/arc4.c \
|
||||
peripherals/sdk/src/core/partition/partition.c \
|
||||
peripherals/sdk/src/core/mdev/mdev.c \
|
||||
peripherals/sdk/src/core/util/flash.c \
|
||||
peripherals/sdk/src/core/util/boot_flags.c \
|
||||
peripherals/boot2/boot2.c \
|
||||
peripherals/boot2/utils/crc32.c \
|
||||
peripherals/platform_uart.c \
|
||||
peripherals/platform_flash.c \
|
||||
platform_init.c
|
||||
|
||||
GLOBAL_INCLUDES += peripherals/boot2
|
||||
|
||||
GLOBAL_DEFINES += CONFIG_FLASH_PARTITION_COUNT=10 \
|
||||
ARM_GNU
|
||||
|
||||
endif
|
||||
|
||||
ifneq ($(filter spi_flash_write, $(APP)),)
|
||||
####################################################################################
|
||||
# Building spi_flash_write
|
||||
####################################################################################
|
||||
|
||||
DEFAULT_LINK_SCRIPT := $(TOOLCHAIN_NAME)/app_ram$(LINK_SCRIPT_SUFFIX)
|
||||
GLOBAL_DEFINES += __JTAG_FLASH_WRITER_DATA_BUFFER_SIZE__=16384
|
||||
|
||||
else
|
||||
ifneq ($(filter $(subst ., ,$(COMPONENTS)),mocOS),)
|
||||
####################################################################################
|
||||
# Building standard moc application
|
||||
####################################################################################
|
||||
|
||||
DEFAULT_LINK_SCRIPT := $(TOOLCHAIN_NAME)/app_with_moc$(LINK_SCRIPT_SUFFIX)
|
||||
|
||||
endif # APP=moc
|
||||
endif # APP=spi_flash_write
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
[total]
|
||||
number=0x04
|
||||
output=full.bin
|
||||
|
||||
[bin1]
|
||||
name=boot2.bin
|
||||
offset=0
|
||||
[bin2]
|
||||
name=mico_ota.bin
|
||||
offset=0x6000
|
||||
[bin3]
|
||||
name=uart_wifi_bridge.bin
|
||||
offset=0x160000
|
||||
[bin4]
|
||||
name=mw30x_uapsta_14.76.36.p84.bin
|
||||
offset=0x1a0000
|
||||
|
||||
|
||||
[total]
|
||||
number=0x04
|
||||
output=full.bin
|
||||
|
||||
[bin1]
|
||||
name=boot2.bin
|
||||
offset=0
|
||||
[bin2]
|
||||
name=mico_ota.bin
|
||||
offset=0x6000
|
||||
[bin3]
|
||||
name=uart_wifi_bridge.bin
|
||||
offset=0x160000
|
||||
[bin4]
|
||||
name=mw30x_uapsta_14.76.36.p84.bin
|
||||
offset=0x1a0000
|
||||
|
||||
|
||||
|
||||
@@ -1,52 +1,56 @@
|
||||
#ifndef _LWIP_API_DEFINE_
|
||||
#define _LWIP_API_DEFINE_
|
||||
|
||||
#include "stdint.h"
|
||||
#include "mico_socket.h"
|
||||
|
||||
typedef struct ip_addr {
|
||||
uint32_t addr;
|
||||
} ip_addr_t;
|
||||
|
||||
|
||||
|
||||
typedef struct _lwip_api_ {
|
||||
int (*lwip_accept)(int s, struct sockaddr *addr, socklen_t *addrlen);
|
||||
int (*lwip_bind)(int s, const struct sockaddr *name, socklen_t namelen);
|
||||
int (*lwip_shutdown)(int s, int how);
|
||||
int (*lwip_getpeername) (int s, struct sockaddr *name, socklen_t *namelen);
|
||||
int (*lwip_getsockname) (int s, struct sockaddr *name, socklen_t *namelen);
|
||||
int (*lwip_getsockopt) (int s, int level, int optname, void *optval, socklen_t *optlen);
|
||||
int (*lwip_setsockopt) (int s, int level, int optname, const void *optval, socklen_t optlen);
|
||||
int (*lwip_close)(int s);
|
||||
int (*lwip_connect)(int s, const struct sockaddr *name, socklen_t namelen);
|
||||
int (*lwip_listen)(int s, int backlog);
|
||||
int (*lwip_recv)(int s, void *mem, size_t len, int flags);
|
||||
int (*lwip_read)(int s, void *mem, size_t len);
|
||||
int (*lwip_recvfrom)(int s, void *mem, size_t len, int flags,
|
||||
struct sockaddr *from, socklen_t *fromlen);
|
||||
int (*lwip_send)(int s, const void *dataptr, size_t size, int flags);
|
||||
int (*lwip_sendto)(int s, const void *dataptr, size_t size, int flags,
|
||||
const struct sockaddr *to, socklen_t tolen);
|
||||
int (*lwip_socket)(int domain, int type, int protocol);
|
||||
int (*lwip_write)(int s, const void *dataptr, size_t size);
|
||||
int (*lwip_select)(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
||||
struct timeval *timeout);
|
||||
int (*lwip_ioctl)(int s, long cmd, void *argp);
|
||||
int (*lwip_fcntl)(int s, int cmd, int val);
|
||||
|
||||
void (*lwip_freeaddrinfo)(struct addrinfo *ai);
|
||||
int (*lwip_getaddrinfo)(const char *nodename,
|
||||
const char *servname,
|
||||
const struct addrinfo *hints,
|
||||
struct addrinfo **res);
|
||||
|
||||
char * (*ipaddr_ntoa)(const ip_addr_t *addr);
|
||||
uint32_t (*ipaddr_addr)(const char *cp);
|
||||
struct hostent * (*lwip_gethostbyname) (const char *name);
|
||||
char *(*sethostname)( char *name );
|
||||
char* (*get_dhcp_classid)( void );
|
||||
char* (*set_dhcp_classid)( char *classid );
|
||||
} lwip_api_t;
|
||||
|
||||
#endif
|
||||
#ifndef _LWIP_API_DEFINE_
|
||||
#define _LWIP_API_DEFINE_
|
||||
|
||||
#include "stdint.h"
|
||||
#include "mico_socket.h"
|
||||
|
||||
typedef struct ip_addr {
|
||||
uint32_t addr;
|
||||
} ip_addr_t;
|
||||
|
||||
|
||||
|
||||
typedef struct _lwip_api_ {
|
||||
int (*lwip_accept)(int s, struct sockaddr *addr, socklen_t *addrlen);
|
||||
int (*lwip_bind)(int s, const struct sockaddr *name, socklen_t namelen);
|
||||
int (*lwip_shutdown)(int s, int how);
|
||||
int (*lwip_getpeername) (int s, struct sockaddr *name, socklen_t *namelen);
|
||||
int (*lwip_getsockname) (int s, struct sockaddr *name, socklen_t *namelen);
|
||||
int (*lwip_getsockopt) (int s, int level, int optname, void *optval, socklen_t *optlen);
|
||||
int (*lwip_setsockopt) (int s, int level, int optname, const void *optval, socklen_t optlen);
|
||||
int (*lwip_close)(int s);
|
||||
int (*lwip_connect)(int s, const struct sockaddr *name, socklen_t namelen);
|
||||
int (*lwip_listen)(int s, int backlog);
|
||||
int (*lwip_recv)(int s, void *mem, size_t len, int flags);
|
||||
int (*lwip_read)(int s, void *mem, size_t len);
|
||||
int (*lwip_recvfrom)(int s, void *mem, size_t len, int flags,
|
||||
struct sockaddr *from, socklen_t *fromlen);
|
||||
int (*lwip_send)(int s, const void *dataptr, size_t size, int flags);
|
||||
int (*lwip_sendto)(int s, const void *dataptr, size_t size, int flags,
|
||||
const struct sockaddr *to, socklen_t tolen);
|
||||
int (*lwip_socket)(int domain, int type, int protocol);
|
||||
int (*lwip_write)(int s, const void *dataptr, size_t size);
|
||||
int (*lwip_select)(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
||||
struct timeval *timeout);
|
||||
int (*lwip_ioctl)(int s, long cmd, void *argp);
|
||||
int (*lwip_fcntl)(int s, int cmd, int val);
|
||||
|
||||
void (*lwip_freeaddrinfo)(struct addrinfo *ai);
|
||||
int (*lwip_getaddrinfo)(const char *nodename,
|
||||
const char *servname,
|
||||
const struct addrinfo *hints,
|
||||
struct addrinfo **res);
|
||||
|
||||
char * (*ipaddr_ntoa)(const ip_addr_t *addr);
|
||||
uint32_t (*ipaddr_addr)(const char *cp);
|
||||
struct hostent * (*lwip_gethostbyname) (const char *name);
|
||||
char *(*sethostname)( char *name );
|
||||
char* (*get_dhcp_classid)( void );
|
||||
char* (*set_dhcp_classid)( char *classid );
|
||||
|
||||
/* For inet_ntop and inet_pton */
|
||||
const char * (*inet_ntop) (int af, const void *cp, char *buf, socklen_t len);
|
||||
int (*inet_pton) (int af, const char *cp, void *buf);
|
||||
} lwip_api_t;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,292 +1,325 @@
|
||||
#include "debug.h"
|
||||
#include "common.h"
|
||||
#include "moc_api.h"
|
||||
#include "moc_api_sep.h"
|
||||
|
||||
static kernel_api_t _kernel_api;
|
||||
|
||||
static mico_system_config_t* _system_config_get( void )
|
||||
{
|
||||
static mico_system_config_t cfg;
|
||||
// _kernel_api.os_apis->system_config(0, &cfg);
|
||||
printf("config get\r\n");
|
||||
return &cfg;
|
||||
}
|
||||
|
||||
static void _system_config_set( mico_system_config_t *cfg )
|
||||
{
|
||||
//_kernel_api.os_apis->system_config(1, cfg);
|
||||
printf("config set");
|
||||
}
|
||||
|
||||
#ifndef MICO_DISABLE_STDIO
|
||||
|
||||
#ifndef STDIO_BUFFER_SIZE
|
||||
#define STDIO_BUFFER_SIZE 64
|
||||
#endif
|
||||
|
||||
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];
|
||||
|
||||
void init_debug_uart(void)
|
||||
{
|
||||
ring_buffer_init( (ring_buffer_t*) &stdio_rx_buffer, (uint8_t*) stdio_rx_data, STDIO_BUFFER_SIZE );
|
||||
MicoUartInitialize(STDIO_UART, &stdio_uart_config,
|
||||
(ring_buffer_t*) &stdio_rx_buffer );
|
||||
}
|
||||
#endif
|
||||
|
||||
mico_api_t *moc_adapter(new_mico_api_t *new_mico_api)
|
||||
{
|
||||
static mico_api_t mico_api;
|
||||
new_mico_api->mico_api_get(API_VERSION_V1, &_kernel_api);
|
||||
|
||||
/* automatically generated by python script */
|
||||
mico_api.library_version = new_mico_api->library_version;
|
||||
|
||||
mico_api.system_config_get = _system_config_get;
|
||||
mico_api.system_config_set = _system_config_set;
|
||||
mico_api.mxchipInit = (void(*)())_kernel_api.os_apis->mxchipInit;
|
||||
|
||||
mico_api.mico_rtos_create_thread = (int (*)(void **, uint8_t, char const *, void (*)(uint32_t), uint32_t, void *))_kernel_api.os_apis->mico_rtos_create_thread;
|
||||
mico_api.mico_rtos_delete_thread = _kernel_api.os_apis->mico_rtos_delete_thread;
|
||||
mico_api.mico_rtos_suspend_thread = _kernel_api.os_apis->mico_rtos_suspend_thread;
|
||||
mico_api.mico_rtos_suspend_all_thread = _kernel_api.os_apis->mico_rtos_suspend_all_thread;
|
||||
mico_api.mico_rtos_resume_all_thread = (long(*)(void))_kernel_api.os_apis->mico_rtos_resume_all_thread;
|
||||
mico_api.mico_rtos_thread_join = _kernel_api.os_apis->mico_rtos_thread_join;
|
||||
mico_api.mico_rtos_thread_force_awake = _kernel_api.os_apis->mico_rtos_thread_force_awake;
|
||||
mico_api.mico_rtos_is_current_thread = _kernel_api.os_apis->mico_rtos_is_current_thread;
|
||||
mico_api.mico_thread_sleep = _kernel_api.os_apis->mico_thread_sleep;
|
||||
mico_api.mico_thread_msleep = _kernel_api.os_apis->mico_thread_msleep;
|
||||
mico_api.mico_rtos_init_semaphore = _kernel_api.os_apis->mico_rtos_init_semaphore;
|
||||
mico_api.mico_rtos_set_semaphore = _kernel_api.os_apis->mico_rtos_set_semaphore;
|
||||
mico_api.mico_rtos_get_semaphore = _kernel_api.os_apis->mico_rtos_get_semaphore;
|
||||
mico_api.mico_rtos_deinit_semaphore = _kernel_api.os_apis->mico_rtos_deinit_semaphore;
|
||||
mico_api.mico_rtos_init_mutex = _kernel_api.os_apis->mico_rtos_init_mutex;
|
||||
mico_api.mico_rtos_lock_mutex = _kernel_api.os_apis->mico_rtos_lock_mutex;
|
||||
mico_api.mico_rtos_unlock_mutex = _kernel_api.os_apis->mico_rtos_unlock_mutex;
|
||||
mico_api.mico_rtos_deinit_mutex = _kernel_api.os_apis->mico_rtos_deinit_mutex;
|
||||
mico_api.mico_rtos_init_queue = _kernel_api.os_apis->mico_rtos_init_queue;
|
||||
mico_api.mico_rtos_push_to_queue = _kernel_api.os_apis->mico_rtos_push_to_queue;
|
||||
mico_api.mico_rtos_pop_from_queue = _kernel_api.os_apis->mico_rtos_pop_from_queue;
|
||||
mico_api.mico_rtos_deinit_queue = _kernel_api.os_apis->mico_rtos_deinit_queue;
|
||||
mico_api.mico_rtos_is_queue_empty = _kernel_api.os_apis->mico_rtos_is_queue_empty;
|
||||
mico_api.mico_rtos_is_queue_full = (int (*)(void * *))_kernel_api.os_apis->mico_rtos_is_queue_full;
|
||||
mico_api.mico_get_time = _kernel_api.os_apis->mico_get_time;
|
||||
mico_api.mico_init_timer = _kernel_api.os_apis->mico_init_timer;
|
||||
mico_api.mico_start_timer = _kernel_api.os_apis->mico_start_timer;
|
||||
mico_api.mico_stop_timer = _kernel_api.os_apis->mico_stop_timer;
|
||||
mico_api.mico_reload_timer = _kernel_api.os_apis->mico_reload_timer;
|
||||
mico_api.mico_deinit_timer = _kernel_api.os_apis->mico_deinit_timer;
|
||||
mico_api.mico_is_timer_running = _kernel_api.os_apis->mico_is_timer_running;
|
||||
mico_api.mico_create_event_fd = _kernel_api.os_apis->mico_create_event_fd;
|
||||
mico_api.mico_delete_event_fd = _kernel_api.os_apis->mico_delete_event_fd;
|
||||
mico_api.SetTimer = NULL;
|
||||
mico_api.SetTimer_uniq = NULL;
|
||||
mico_api.UnSetTimer = NULL;
|
||||
mico_api.mico_memory_info = (micoMemInfo_t* (*)( void ))_kernel_api.os_apis->mico_memory_info;
|
||||
mico_api.malloc = _kernel_api.os_apis->malloc;
|
||||
mico_api.realloc = _kernel_api.os_apis->realloc;
|
||||
mico_api.free = _kernel_api.os_apis->free;
|
||||
mico_api.calloc = (void *(*)(int, int))_kernel_api.os_apis->calloc;
|
||||
mico_api.heap_insert = _kernel_api.os_apis->heap_insert;
|
||||
|
||||
mico_api.socket = NULL;
|
||||
mico_api.setsockopt = NULL;
|
||||
mico_api.getsockopt = NULL;
|
||||
mico_api.bind = NULL;
|
||||
mico_api.connect = NULL;
|
||||
mico_api.listen = NULL;
|
||||
mico_api.accept = NULL;
|
||||
mico_api.select = NULL;
|
||||
mico_api.send = NULL;
|
||||
mico_api.write = NULL;
|
||||
mico_api.sendto = NULL;
|
||||
mico_api.recv = NULL;
|
||||
mico_api.read = NULL;
|
||||
mico_api.recvfrom = NULL;
|
||||
mico_api.close = NULL;
|
||||
mico_api.inet_addr = NULL;
|
||||
mico_api.inet_ntoa = NULL;
|
||||
mico_api.gethostbyname = NULL;
|
||||
mico_api.set_tcp_keepalive = NULL;
|
||||
mico_api.get_tcp_keepalive = NULL;
|
||||
|
||||
mico_api.lwip_apis = _kernel_api.lwip_apis;
|
||||
|
||||
mico_api.ssl_set_cert = _kernel_api.ssl_crypto_apis->ssl_set_cert;
|
||||
mico_api.ssl_connect = _kernel_api.ssl_crypto_apis->ssl_connect;
|
||||
mico_api.ssl_accept = _kernel_api.ssl_crypto_apis->ssl_accept;
|
||||
mico_api.ssl_send = _kernel_api.ssl_crypto_apis->ssl_send;
|
||||
mico_api.ssl_recv = _kernel_api.ssl_crypto_apis->ssl_recv;
|
||||
mico_api.ssl_close = _kernel_api.ssl_crypto_apis->ssl_close;
|
||||
mico_api.set_ssl_client_version = _kernel_api.ssl_crypto_apis->set_ssl_client_version;
|
||||
mico_api.ssl_nonblock_connect = _kernel_api.ssl_crypto_apis->ssl_nonblock_connect;
|
||||
mico_api.ssl_set_using_nonblock = _kernel_api.ssl_crypto_apis->ssl_set_using_nonblock;
|
||||
mico_api.ssl_pending = _kernel_api.ssl_crypto_apis->ssl_pending;
|
||||
mico_api.ssl_get_error = _kernel_api.ssl_crypto_apis->ssl_get_error;
|
||||
mico_api.ssl_set_client_cert = _kernel_api.ssl_crypto_apis->ssl_set_client_cert;
|
||||
mico_api.ssl_connect_sni = _kernel_api.ssl_crypto_apis->ssl_connect_sni;
|
||||
|
||||
mico_api.InitMd5 = (void (*)(md5_context*))_kernel_api.ssl_crypto_apis->InitMd5;
|
||||
mico_api.Md5Update = (void (*)(md5_context*,unsigned char*, int))_kernel_api.ssl_crypto_apis->Md5Update;
|
||||
mico_api.Md5Final = (void (*)(md5_context*,uint8_t*))_kernel_api.ssl_crypto_apis->Md5Final;
|
||||
mico_api.Md5Hash = _kernel_api.ssl_crypto_apis->Md5Hash;
|
||||
mico_api.AesEncryptDirect = _kernel_api.ssl_crypto_apis->AesEncryptDirect;
|
||||
mico_api.AesDecryptDirect = _kernel_api.ssl_crypto_apis->AesDecryptDirect;
|
||||
mico_api.AesSetKeyDirect = _kernel_api.ssl_crypto_apis->AesSetKeyDirect;
|
||||
mico_api.aes_encrypt = _kernel_api.ssl_crypto_apis->aes_encrypt;
|
||||
mico_api.aes_decrypt = _kernel_api.ssl_crypto_apis->aes_decrypt;
|
||||
mico_api.AesSetKey = _kernel_api.ssl_crypto_apis->AesSetKey;
|
||||
mico_api.AesSetIV = _kernel_api.ssl_crypto_apis->AesSetIV;
|
||||
mico_api.AesCbcEncrypt = _kernel_api.ssl_crypto_apis->AesCbcEncrypt;
|
||||
mico_api.AesCbcDecrypt = _kernel_api.ssl_crypto_apis->AesCbcDecrypt;
|
||||
|
||||
mico_api.wlan_get_mac_address = _kernel_api.wifi_apis->wlan_get_mac_address;
|
||||
mico_api.wlan_get_mac_address_by_interface = _kernel_api.wifi_apis->wlan_get_mac_address_by_interface;
|
||||
mico_api.mico_wlan_get_channel = _kernel_api.wifi_apis->mico_wlan_get_channel;
|
||||
mico_api.wlan_driver_version = _kernel_api.wifi_apis->wlan_driver_version;
|
||||
mico_api.micoWlanStart = _kernel_api.wifi_apis->micoWlanStart;
|
||||
mico_api.micoWlanStartAdv = _kernel_api.wifi_apis->micoWlanStartAdv;
|
||||
mico_api.micoWlanGetIPStatus = _kernel_api.wifi_apis->micoWlanGetIPStatus;
|
||||
mico_api.micoWlanGetLinkStatus = _kernel_api.wifi_apis->micoWlanGetLinkStatus;
|
||||
mico_api.micoWlanStartScan = (int(*)(void))_kernel_api.wifi_apis->micoWlanStartScan;
|
||||
mico_api.micoWlanStartScanAdv = (int(*)(void))_kernel_api.wifi_apis->micoWlanStartScanAdv;
|
||||
mico_api.micoWlanPowerOff = _kernel_api.wifi_apis->micoWlanPowerOff;
|
||||
mico_api.micoWlanPowerOn = _kernel_api.wifi_apis->micoWlanPowerOn;
|
||||
mico_api.micoWlanSuspend = _kernel_api.wifi_apis->micoWlanSuspend;
|
||||
mico_api.micoWlanSuspendStation = _kernel_api.wifi_apis->micoWlanSuspendStation;
|
||||
mico_api.micoWlanSuspendSoftAP = _kernel_api.wifi_apis->micoWlanSuspendSoftAP;
|
||||
mico_api.micoWlanStartEasyLink = _kernel_api.wifi_apis->micoWlanStartEasyLink;
|
||||
mico_api.micoWlanStartEasyLinkPlus = _kernel_api.wifi_apis->micoWlanStartEasyLink;
|
||||
mico_api.micoWlanStopEasyLink = _kernel_api.wifi_apis->micoWlanStopEasyLink;
|
||||
mico_api.micoWlanStopEasyLinkPlus = _kernel_api.wifi_apis->micoWlanStopEasyLink;
|
||||
mico_api.micoWlanStartWPS = NULL;
|
||||
mico_api.micoWlanStopWPS = NULL;
|
||||
mico_api.micoWlanStartAirkiss = _kernel_api.wifi_apis->micoWlanStartEasyLink;
|
||||
mico_api.micoWlanStopAirkiss = _kernel_api.wifi_apis->micoWlanStopEasyLink;
|
||||
mico_api.micoWlanEnablePowerSave = _kernel_api.wifi_apis->micoWlanEnablePowerSave;
|
||||
mico_api.micoWlanDisablePowerSave = _kernel_api.wifi_apis->micoWlanDisablePowerSave;
|
||||
mico_api.wifimgr_debug_enable = _kernel_api.wifi_apis->wifimgr_debug_enable;
|
||||
mico_api.mico_wlan_monitor_rx_type = _kernel_api.wifi_apis->mico_wlan_monitor_rx_type;
|
||||
mico_api.mico_wlan_start_monitor = _kernel_api.wifi_apis->mico_wlan_start_monitor;
|
||||
mico_api.mico_wlan_stop_monitor = _kernel_api.wifi_apis->mico_wlan_stop_monitor;
|
||||
mico_api.mico_wlan_set_channel = _kernel_api.wifi_apis->mico_wlan_set_channel;
|
||||
mico_api.mico_wlan_register_monitor_cb = _kernel_api.wifi_apis->mico_wlan_register_monitor_cb;
|
||||
mico_api.wlan_set_channel = _kernel_api.wifi_apis->wlan_set_channel;
|
||||
mico_api.mxchip_active_scan = _kernel_api.wifi_apis->mxchip_active_scan;
|
||||
mico_api.wifi_manage_custom_ie_add = _kernel_api.wifi_apis->wifi_manage_custom_ie_add;
|
||||
mico_api.wifi_manage_custom_ie_delete = _kernel_api.wifi_apis->wifi_manage_custom_ie_delete;
|
||||
|
||||
mico_api.cli_init = _kernel_api.cli_apis->cli_init;
|
||||
mico_api.cli_register_command = _kernel_api.cli_apis->cli_register_command;
|
||||
mico_api.cli_unregister_command = _kernel_api.cli_apis->cli_unregister_command;
|
||||
mico_api.wifistate_Command = _kernel_api.cli_apis->wifistate_Command;
|
||||
mico_api.wifidebug_Command = _kernel_api.cli_apis->wifidebug_Command;
|
||||
mico_api.wifiscan_Command = _kernel_api.cli_apis->wifiscan_Command;
|
||||
mico_api.ifconfig_Command = _kernel_api.cli_apis->ifconfig_Command;
|
||||
mico_api.arp_Command = _kernel_api.cli_apis->arp_Command;
|
||||
mico_api.ping_Command = _kernel_api.cli_apis->ping_Command;
|
||||
mico_api.dns_Command = _kernel_api.cli_apis->dns_Command;
|
||||
mico_api.task_Command = _kernel_api.cli_apis->task_Command;
|
||||
mico_api.socket_show_Command = _kernel_api.cli_apis->socket_show_Command;
|
||||
mico_api.memory_show_Command = _kernel_api.cli_apis->memory_show_Command;
|
||||
mico_api.memory_dump_Command = _kernel_api.cli_apis->memory_dump_Command;
|
||||
mico_api.memory_set_Command = _kernel_api.cli_apis->memory_set_Command;
|
||||
mico_api.memp_dump_Command = _kernel_api.cli_apis->memp_dump_Command;
|
||||
mico_api.driver_state_Command = _kernel_api.cli_apis->driver_state_Command;
|
||||
mico_api.iperf_Command = _kernel_api.cli_apis->iperf_Command;
|
||||
|
||||
mico_api.MicoFlashGetInfo = _kernel_api.flash_apis->MicoFlashGetInfo;
|
||||
mico_api.MicoFlashErase = _kernel_api.flash_apis->MicoFlashErase;
|
||||
mico_api.MicoFlashWrite = _kernel_api.flash_apis->MicoFlashWrite;
|
||||
mico_api.MicoFlashRead = _kernel_api.flash_apis->MicoFlashRead;
|
||||
mico_api.MicoFlashEnableSecurity = _kernel_api.flash_apis->MicoFlashEnableSecurity;
|
||||
mico_api.MicoGpioInitialize = _kernel_api.gpio_apis->MicoGpioInitialize;
|
||||
mico_api.MicoGpioFinalize = _kernel_api.gpio_apis->MicoGpioFinalize;
|
||||
mico_api.MicoGpioOutputHigh = _kernel_api.gpio_apis->MicoGpioOutputHigh;
|
||||
mico_api.MicoGpioOutputLow = _kernel_api.gpio_apis->MicoGpioOutputLow;
|
||||
mico_api.MicoGpioOutputTrigger = _kernel_api.gpio_apis->MicoGpioOutputTrigger;
|
||||
mico_api.MicoGpioInputGet = _kernel_api.gpio_apis->MicoGpioInputGet;
|
||||
mico_api.MicoGpioEnableIRQ = _kernel_api.gpio_apis->MicoGpioEnableIRQ;
|
||||
mico_api.MicoGpioDisableIRQ = _kernel_api.gpio_apis->MicoGpioDisableIRQ;
|
||||
mico_api.MicoUartInitialize = _kernel_api.uart_apis->MicoUartInitialize;
|
||||
mico_api.MicoUartFinalize = _kernel_api.uart_apis->MicoUartFinalize;
|
||||
mico_api.MicoUartSend = _kernel_api.uart_apis->MicoUartSend;
|
||||
mico_api.MicoUartRecv = _kernel_api.uart_apis->MicoUartRecv;
|
||||
mico_api.MicoUartGetLengthInBuffer = _kernel_api.uart_apis->MicoUartGetLengthInBuffer;
|
||||
mico_api.MicoUartPinRedirect = _kernel_api.uart_apis->MicoUartPinRedirect;
|
||||
|
||||
mico_api.pm_mcu_state = _kernel_api.ps_apis->pm_mcu_state;
|
||||
mico_api.pm_wakeup_source = _kernel_api.ps_apis->pm_wakeup_source;
|
||||
mico_api.wifi_off_mcu_standby = (void(*)(int))(_kernel_api.ps_apis->wifi_off_mcu_standby);
|
||||
mico_api.MicoMcuPowerSaveConfig = _kernel_api.ps_apis->MicoMcuPowerSaveConfig;
|
||||
mico_api.debug_putchar = _kernel_api.os_apis->debug_putchar;
|
||||
mico_api.MicoSystemReboot = _kernel_api.os_apis->MicoSystemReboot;
|
||||
mico_api.get_ali_key = NULL;
|
||||
mico_api.get_ali_secret = NULL;
|
||||
mico_api.MicoRtcInitialize = _kernel_api.rtc_apis->MicoRtcInitialize;
|
||||
mico_api.MicoRtcGetTime = _kernel_api.rtc_apis->MicoRtcGetTime;
|
||||
mico_api.MicoRtcSetTime = _kernel_api.rtc_apis->MicoRtcSetTime;
|
||||
mico_api.localtime = _kernel_api.os_apis->localtime;
|
||||
mico_api.asctime = _kernel_api.os_apis->asctime;
|
||||
mico_api.wifi_set_country = _kernel_api.wifi_apis->wifi_set_country;
|
||||
mico_api.switch_active_firmrware = NULL;
|
||||
mico_api.last_reset_reason = _kernel_api.os_apis->last_reset_reason;
|
||||
mico_api.aon_write = _kernel_api.os_apis->aon_write;
|
||||
mico_api.aon_read = _kernel_api.os_apis->aon_read;
|
||||
mico_api.ssl_get_fd = _kernel_api.ssl_crypto_apis->ssl_get_fd;
|
||||
mico_api.get_random_sequence = _kernel_api.os_apis->get_random_sequence;
|
||||
mico_api.ssl_set_loggingcb = _kernel_api.ssl_crypto_apis->ssl_loggingcb;
|
||||
mico_api.wlan_inject_frame = _kernel_api.wifi_apis->wlan_inject_frame;
|
||||
mico_api.wlan_rx_mgmt_indication = NULL;
|
||||
mico_api.wlan_remain_on_channel = NULL;
|
||||
mico_api.wifi_bridge_mode_enable = NULL;
|
||||
mico_api.wifi_bridge_mode_disable = NULL;
|
||||
mico_api.send_easylink_minus = _kernel_api.wifi_apis->send_easylink_minus;
|
||||
mico_api.ssl_socket = (int(*)(void*))(_kernel_api.ssl_crypto_apis->ssl_get_fd);
|
||||
|
||||
mico_api.i2c_apis = _kernel_api.i2c_apis;
|
||||
mico_api.spi_apis = _kernel_api.spi_apis;
|
||||
mico_api.pwm_apis = _kernel_api.pwm_apis;
|
||||
mico_api.wdg_apis = _kernel_api.wdg_apis;
|
||||
mico_api.adc_apis = _kernel_api.adc_apis;
|
||||
|
||||
return &mico_api;
|
||||
}
|
||||
|
||||
int debug_putchar(char *ch, int len)
|
||||
{
|
||||
return _kernel_api.os_apis->debug_putchar(ch, len);
|
||||
}
|
||||
|
||||
int debug_gettchar(char *ch)
|
||||
{
|
||||
return _kernel_api.os_apis->debug_getchar(ch);
|
||||
}
|
||||
|
||||
int mico_wlan_monitor_no_easylink(void)
|
||||
{
|
||||
return _kernel_api.wifi_apis->mico_wlan_monitor_no_easylink();
|
||||
}
|
||||
|
||||
int wlan_rx_mgnt_set(int enable, mgnt_handler_t cb)
|
||||
{
|
||||
return _kernel_api.wifi_apis->wlan_rx_mgnt_set(enable, cb);
|
||||
}
|
||||
|
||||
void autoconfig_start(int seconds, int mode)
|
||||
{
|
||||
_kernel_api.wifi_apis->autoconfig_start(seconds, mode);
|
||||
}
|
||||
|
||||
#include "debug.h"
|
||||
#include "common.h"
|
||||
#include "moc_api.h"
|
||||
#include "moc_api_sep.h"
|
||||
|
||||
static kernel_api_t _kernel_api;
|
||||
|
||||
static mico_system_config_t* _system_config_get( void )
|
||||
{
|
||||
static mico_system_config_t cfg;
|
||||
// _kernel_api.os_apis->system_config(0, &cfg);
|
||||
printf("config get\r\n");
|
||||
return &cfg;
|
||||
}
|
||||
|
||||
static void _system_config_set( mico_system_config_t *cfg )
|
||||
{
|
||||
//_kernel_api.os_apis->system_config(1, cfg);
|
||||
printf("config set");
|
||||
}
|
||||
|
||||
#ifndef MICO_DISABLE_STDIO
|
||||
|
||||
#ifndef STDIO_BUFFER_SIZE
|
||||
#define STDIO_BUFFER_SIZE 64
|
||||
#endif
|
||||
|
||||
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];
|
||||
|
||||
void init_debug_uart(void)
|
||||
{
|
||||
ring_buffer_init( (ring_buffer_t*) &stdio_rx_buffer, (uint8_t*) stdio_rx_data, STDIO_BUFFER_SIZE );
|
||||
MicoUartInitialize(STDIO_UART, &stdio_uart_config,
|
||||
(ring_buffer_t*) &stdio_rx_buffer );
|
||||
}
|
||||
#else
|
||||
void init_debug_uart(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
mico_api_t *moc_adapter(new_mico_api_t *new_mico_api)
|
||||
{
|
||||
static mico_api_t mico_api;
|
||||
new_mico_api->mico_api_get(API_VERSION_V1, &_kernel_api);
|
||||
|
||||
/* automatically generated by python script */
|
||||
mico_api.library_version = new_mico_api->library_version;
|
||||
|
||||
mico_api.system_config_get = _system_config_get;
|
||||
mico_api.system_config_set = _system_config_set;
|
||||
mico_api.mxchipInit = (void(*)())_kernel_api.os_apis->mxchipInit;
|
||||
|
||||
mico_api.mico_rtos_create_thread = (int (*)(void **, uint8_t, char const *, void (*)(uint32_t), uint32_t, void *))_kernel_api.os_apis->mico_rtos_create_thread;
|
||||
mico_api.mico_rtos_delete_thread = _kernel_api.os_apis->mico_rtos_delete_thread;
|
||||
mico_api.mico_rtos_suspend_thread = _kernel_api.os_apis->mico_rtos_suspend_thread;
|
||||
mico_api.mico_rtos_suspend_all_thread = _kernel_api.os_apis->mico_rtos_suspend_all_thread;
|
||||
mico_api.mico_rtos_resume_all_thread = (long(*)(void))_kernel_api.os_apis->mico_rtos_resume_all_thread;
|
||||
mico_api.mico_rtos_thread_join = _kernel_api.os_apis->mico_rtos_thread_join;
|
||||
mico_api.mico_rtos_thread_force_awake = _kernel_api.os_apis->mico_rtos_thread_force_awake;
|
||||
mico_api.mico_rtos_is_current_thread = _kernel_api.os_apis->mico_rtos_is_current_thread;
|
||||
mico_api.mico_thread_sleep = _kernel_api.os_apis->mico_thread_sleep;
|
||||
mico_api.mico_thread_msleep = _kernel_api.os_apis->mico_thread_msleep;
|
||||
mico_api.mico_rtos_init_semaphore = _kernel_api.os_apis->mico_rtos_init_semaphore;
|
||||
mico_api.mico_rtos_set_semaphore = _kernel_api.os_apis->mico_rtos_set_semaphore;
|
||||
mico_api.mico_rtos_get_semaphore = _kernel_api.os_apis->mico_rtos_get_semaphore;
|
||||
mico_api.mico_rtos_deinit_semaphore = _kernel_api.os_apis->mico_rtos_deinit_semaphore;
|
||||
mico_api.mico_rtos_init_mutex = _kernel_api.os_apis->mico_rtos_init_mutex;
|
||||
mico_api.mico_rtos_lock_mutex = _kernel_api.os_apis->mico_rtos_lock_mutex;
|
||||
mico_api.mico_rtos_unlock_mutex = _kernel_api.os_apis->mico_rtos_unlock_mutex;
|
||||
mico_api.mico_rtos_deinit_mutex = _kernel_api.os_apis->mico_rtos_deinit_mutex;
|
||||
mico_api.mico_rtos_init_queue = _kernel_api.os_apis->mico_rtos_init_queue;
|
||||
mico_api.mico_rtos_push_to_queue = _kernel_api.os_apis->mico_rtos_push_to_queue;
|
||||
mico_api.mico_rtos_pop_from_queue = _kernel_api.os_apis->mico_rtos_pop_from_queue;
|
||||
mico_api.mico_rtos_deinit_queue = _kernel_api.os_apis->mico_rtos_deinit_queue;
|
||||
mico_api.mico_rtos_is_queue_empty = _kernel_api.os_apis->mico_rtos_is_queue_empty;
|
||||
mico_api.mico_rtos_is_queue_full = (int (*)(void * *))_kernel_api.os_apis->mico_rtos_is_queue_full;
|
||||
mico_api.mico_get_time = _kernel_api.os_apis->mico_get_time;
|
||||
mico_api.mico_init_timer = _kernel_api.os_apis->mico_init_timer;
|
||||
mico_api.mico_start_timer = _kernel_api.os_apis->mico_start_timer;
|
||||
mico_api.mico_stop_timer = _kernel_api.os_apis->mico_stop_timer;
|
||||
mico_api.mico_reload_timer = _kernel_api.os_apis->mico_reload_timer;
|
||||
mico_api.mico_deinit_timer = _kernel_api.os_apis->mico_deinit_timer;
|
||||
mico_api.mico_is_timer_running = _kernel_api.os_apis->mico_is_timer_running;
|
||||
mico_api.mico_create_event_fd = _kernel_api.os_apis->mico_create_event_fd;
|
||||
mico_api.mico_delete_event_fd = _kernel_api.os_apis->mico_delete_event_fd;
|
||||
mico_api.SetTimer = NULL;
|
||||
mico_api.SetTimer_uniq = NULL;
|
||||
mico_api.UnSetTimer = NULL;
|
||||
mico_api.mico_memory_info = (micoMemInfo_t* (*)( void ))_kernel_api.os_apis->mico_memory_info;
|
||||
mico_api.malloc = _kernel_api.os_apis->malloc;
|
||||
mico_api.realloc = _kernel_api.os_apis->realloc;
|
||||
mico_api.free = _kernel_api.os_apis->free;
|
||||
mico_api.calloc = (void *(*)(int, int))_kernel_api.os_apis->calloc;
|
||||
mico_api.heap_insert = _kernel_api.os_apis->heap_insert;
|
||||
|
||||
mico_api.socket = NULL;
|
||||
mico_api.setsockopt = NULL;
|
||||
mico_api.getsockopt = NULL;
|
||||
mico_api.bind = NULL;
|
||||
mico_api.connect = NULL;
|
||||
mico_api.listen = NULL;
|
||||
mico_api.accept = NULL;
|
||||
mico_api.select = NULL;
|
||||
mico_api.send = NULL;
|
||||
mico_api.write = NULL;
|
||||
mico_api.sendto = NULL;
|
||||
mico_api.recv = NULL;
|
||||
mico_api.read = NULL;
|
||||
mico_api.recvfrom = NULL;
|
||||
mico_api.close = NULL;
|
||||
mico_api.inet_addr = NULL;
|
||||
mico_api.inet_ntoa = NULL;
|
||||
mico_api.gethostbyname = NULL;
|
||||
mico_api.set_tcp_keepalive = NULL;
|
||||
mico_api.get_tcp_keepalive = NULL;
|
||||
|
||||
mico_api.lwip_apis = _kernel_api.lwip_apis;
|
||||
|
||||
mico_api.ssl_set_cert = _kernel_api.ssl_crypto_apis->ssl_set_cert;
|
||||
mico_api.ssl_connect = _kernel_api.ssl_crypto_apis->ssl_connect;
|
||||
mico_api.ssl_accept = _kernel_api.ssl_crypto_apis->ssl_accept;
|
||||
mico_api.ssl_send = _kernel_api.ssl_crypto_apis->ssl_send;
|
||||
mico_api.ssl_recv = _kernel_api.ssl_crypto_apis->ssl_recv;
|
||||
mico_api.ssl_close = _kernel_api.ssl_crypto_apis->ssl_close;
|
||||
mico_api.set_ssl_client_version = _kernel_api.ssl_crypto_apis->set_ssl_client_version;
|
||||
mico_api.ssl_nonblock_connect = _kernel_api.ssl_crypto_apis->ssl_nonblock_connect;
|
||||
mico_api.ssl_set_using_nonblock = _kernel_api.ssl_crypto_apis->ssl_set_using_nonblock;
|
||||
mico_api.ssl_pending = _kernel_api.ssl_crypto_apis->ssl_pending;
|
||||
mico_api.ssl_get_error = _kernel_api.ssl_crypto_apis->ssl_get_error;
|
||||
mico_api.ssl_set_client_cert = _kernel_api.ssl_crypto_apis->ssl_set_client_cert;
|
||||
mico_api.ssl_connect_sni = _kernel_api.ssl_crypto_apis->ssl_connect_sni;
|
||||
|
||||
mico_api.InitMd5 = (void (*)(md5_context*))_kernel_api.ssl_crypto_apis->InitMd5;
|
||||
mico_api.Md5Update = (void (*)(md5_context*,unsigned char*, int))_kernel_api.ssl_crypto_apis->Md5Update;
|
||||
mico_api.Md5Final = (void (*)(md5_context*,uint8_t*))_kernel_api.ssl_crypto_apis->Md5Final;
|
||||
mico_api.Md5Hash = _kernel_api.ssl_crypto_apis->Md5Hash;
|
||||
mico_api.AesEncryptDirect = _kernel_api.ssl_crypto_apis->AesEncryptDirect;
|
||||
mico_api.AesDecryptDirect = _kernel_api.ssl_crypto_apis->AesDecryptDirect;
|
||||
mico_api.AesSetKeyDirect = _kernel_api.ssl_crypto_apis->AesSetKeyDirect;
|
||||
mico_api.aes_encrypt = _kernel_api.ssl_crypto_apis->aes_encrypt;
|
||||
mico_api.aes_decrypt = _kernel_api.ssl_crypto_apis->aes_decrypt;
|
||||
mico_api.AesSetKey = _kernel_api.ssl_crypto_apis->AesSetKey;
|
||||
mico_api.AesSetIV = _kernel_api.ssl_crypto_apis->AesSetIV;
|
||||
mico_api.AesCbcEncrypt = _kernel_api.ssl_crypto_apis->AesCbcEncrypt;
|
||||
mico_api.AesCbcDecrypt = _kernel_api.ssl_crypto_apis->AesCbcDecrypt;
|
||||
|
||||
mico_api.wlan_get_mac_address = _kernel_api.wifi_apis->wlan_get_mac_address;
|
||||
mico_api.wlan_get_mac_address_by_interface = _kernel_api.wifi_apis->wlan_get_mac_address_by_interface;
|
||||
mico_api.mico_wlan_get_channel = _kernel_api.wifi_apis->mico_wlan_get_channel;
|
||||
mico_api.wlan_driver_version = _kernel_api.wifi_apis->wlan_driver_version;
|
||||
mico_api.micoWlanStart = _kernel_api.wifi_apis->micoWlanStart;
|
||||
mico_api.micoWlanStartAdv = _kernel_api.wifi_apis->micoWlanStartAdv;
|
||||
mico_api.micoWlanGetIPStatus = _kernel_api.wifi_apis->micoWlanGetIPStatus;
|
||||
mico_api.micoWlanGetLinkStatus = _kernel_api.wifi_apis->micoWlanGetLinkStatus;
|
||||
mico_api.micoWlanStartScan = (int(*)(void))_kernel_api.wifi_apis->micoWlanStartScan;
|
||||
mico_api.micoWlanStartScanAdv = (int(*)(void))_kernel_api.wifi_apis->micoWlanStartScanAdv;
|
||||
mico_api.micoWlanPowerOff = _kernel_api.wifi_apis->micoWlanPowerOff;
|
||||
mico_api.micoWlanPowerOn = _kernel_api.wifi_apis->micoWlanPowerOn;
|
||||
mico_api.micoWlanSuspend = _kernel_api.wifi_apis->micoWlanSuspend;
|
||||
mico_api.micoWlanSuspendStation = _kernel_api.wifi_apis->micoWlanSuspendStation;
|
||||
mico_api.micoWlanSuspendSoftAP = _kernel_api.wifi_apis->micoWlanSuspendSoftAP;
|
||||
mico_api.micoWlanStartEasyLink = _kernel_api.wifi_apis->micoWlanStartEasyLink;
|
||||
mico_api.micoWlanStartEasyLinkPlus = _kernel_api.wifi_apis->micoWlanStartEasyLink;
|
||||
mico_api.micoWlanStopEasyLink = _kernel_api.wifi_apis->micoWlanStopEasyLink;
|
||||
mico_api.micoWlanStopEasyLinkPlus = _kernel_api.wifi_apis->micoWlanStopEasyLink;
|
||||
mico_api.micoWlanStartWPS = NULL;
|
||||
mico_api.micoWlanStopWPS = NULL;
|
||||
mico_api.micoWlanStartAirkiss = _kernel_api.wifi_apis->micoWlanStartEasyLink;
|
||||
mico_api.micoWlanStopAirkiss = _kernel_api.wifi_apis->micoWlanStopEasyLink;
|
||||
mico_api.micoWlanEnablePowerSave = _kernel_api.wifi_apis->micoWlanEnablePowerSave;
|
||||
mico_api.micoWlanDisablePowerSave = _kernel_api.wifi_apis->micoWlanDisablePowerSave;
|
||||
mico_api.wifimgr_debug_enable = _kernel_api.wifi_apis->wifimgr_debug_enable;
|
||||
mico_api.mico_wlan_monitor_rx_type = _kernel_api.wifi_apis->mico_wlan_monitor_rx_type;
|
||||
mico_api.mico_wlan_start_monitor = _kernel_api.wifi_apis->mico_wlan_start_monitor;
|
||||
mico_api.mico_wlan_stop_monitor = _kernel_api.wifi_apis->mico_wlan_stop_monitor;
|
||||
mico_api.mico_wlan_set_channel = _kernel_api.wifi_apis->mico_wlan_set_channel;
|
||||
mico_api.mico_wlan_register_monitor_cb = _kernel_api.wifi_apis->mico_wlan_register_monitor_cb;
|
||||
mico_api.wlan_set_channel = _kernel_api.wifi_apis->wlan_set_channel;
|
||||
mico_api.mxchip_active_scan = _kernel_api.wifi_apis->mxchip_active_scan;
|
||||
mico_api.wifi_manage_custom_ie_add = _kernel_api.wifi_apis->wifi_manage_custom_ie_add;
|
||||
mico_api.wifi_manage_custom_ie_delete = _kernel_api.wifi_apis->wifi_manage_custom_ie_delete;
|
||||
|
||||
mico_api.cli_init = _kernel_api.cli_apis->cli_init;
|
||||
mico_api.cli_register_command = _kernel_api.cli_apis->cli_register_command;
|
||||
mico_api.cli_unregister_command = _kernel_api.cli_apis->cli_unregister_command;
|
||||
mico_api.wifistate_Command = _kernel_api.cli_apis->wifistate_Command;
|
||||
mico_api.wifidebug_Command = _kernel_api.cli_apis->wifidebug_Command;
|
||||
mico_api.wifiscan_Command = _kernel_api.cli_apis->wifiscan_Command;
|
||||
mico_api.ifconfig_Command = _kernel_api.cli_apis->ifconfig_Command;
|
||||
mico_api.arp_Command = _kernel_api.cli_apis->arp_Command;
|
||||
mico_api.ping_Command = _kernel_api.cli_apis->ping_Command;
|
||||
mico_api.dns_Command = _kernel_api.cli_apis->dns_Command;
|
||||
mico_api.task_Command = _kernel_api.cli_apis->task_Command;
|
||||
mico_api.socket_show_Command = _kernel_api.cli_apis->socket_show_Command;
|
||||
mico_api.memory_show_Command = _kernel_api.cli_apis->memory_show_Command;
|
||||
mico_api.memory_dump_Command = _kernel_api.cli_apis->memory_dump_Command;
|
||||
mico_api.memory_set_Command = _kernel_api.cli_apis->memory_set_Command;
|
||||
mico_api.memp_dump_Command = _kernel_api.cli_apis->memp_dump_Command;
|
||||
mico_api.driver_state_Command = _kernel_api.cli_apis->driver_state_Command;
|
||||
mico_api.iperf_Command = _kernel_api.cli_apis->iperf_Command;
|
||||
|
||||
mico_api.MicoFlashGetInfo = _kernel_api.flash_apis->MicoFlashGetInfo;
|
||||
mico_api.MicoFlashErase = _kernel_api.flash_apis->MicoFlashErase;
|
||||
mico_api.MicoFlashWrite = _kernel_api.flash_apis->MicoFlashWrite;
|
||||
mico_api.MicoFlashRead = _kernel_api.flash_apis->MicoFlashRead;
|
||||
mico_api.MicoFlashEnableSecurity = _kernel_api.flash_apis->MicoFlashEnableSecurity;
|
||||
mico_api.MicoGpioInitialize = _kernel_api.gpio_apis->MicoGpioInitialize;
|
||||
mico_api.MicoGpioFinalize = _kernel_api.gpio_apis->MicoGpioFinalize;
|
||||
mico_api.MicoGpioOutputHigh = _kernel_api.gpio_apis->MicoGpioOutputHigh;
|
||||
mico_api.MicoGpioOutputLow = _kernel_api.gpio_apis->MicoGpioOutputLow;
|
||||
mico_api.MicoGpioOutputTrigger = _kernel_api.gpio_apis->MicoGpioOutputTrigger;
|
||||
mico_api.MicoGpioInputGet = _kernel_api.gpio_apis->MicoGpioInputGet;
|
||||
mico_api.MicoGpioEnableIRQ = _kernel_api.gpio_apis->MicoGpioEnableIRQ;
|
||||
mico_api.MicoGpioDisableIRQ = _kernel_api.gpio_apis->MicoGpioDisableIRQ;
|
||||
mico_api.MicoUartInitialize = _kernel_api.uart_apis->MicoUartInitialize;
|
||||
mico_api.MicoUartFinalize = _kernel_api.uart_apis->MicoUartFinalize;
|
||||
mico_api.MicoUartSend = _kernel_api.uart_apis->MicoUartSend;
|
||||
mico_api.MicoUartRecv = _kernel_api.uart_apis->MicoUartRecv;
|
||||
mico_api.MicoUartGetLengthInBuffer = _kernel_api.uart_apis->MicoUartGetLengthInBuffer;
|
||||
mico_api.MicoUartPinRedirect = _kernel_api.uart_apis->MicoUartPinRedirect;
|
||||
|
||||
mico_api.pm_mcu_state = _kernel_api.ps_apis->pm_mcu_state;
|
||||
mico_api.pm_wakeup_source = _kernel_api.ps_apis->pm_wakeup_source;
|
||||
mico_api.wifi_off_mcu_standby = (void(*)(int))(_kernel_api.ps_apis->wifi_off_mcu_standby);
|
||||
mico_api.MicoMcuPowerSaveConfig = _kernel_api.ps_apis->MicoMcuPowerSaveConfig;
|
||||
mico_api.debug_putchar = _kernel_api.os_apis->debug_putchar;
|
||||
mico_api.MicoSystemReboot = _kernel_api.os_apis->MicoSystemReboot;
|
||||
mico_api.get_ali_key = NULL;
|
||||
mico_api.get_ali_secret = NULL;
|
||||
mico_api.MicoRtcInitialize = _kernel_api.rtc_apis->MicoRtcInitialize;
|
||||
mico_api.MicoRtcGetTime = _kernel_api.rtc_apis->MicoRtcGetTime;
|
||||
mico_api.MicoRtcSetTime = _kernel_api.rtc_apis->MicoRtcSetTime;
|
||||
mico_api.localtime = _kernel_api.os_apis->localtime;
|
||||
mico_api.asctime = _kernel_api.os_apis->asctime;
|
||||
mico_api.wifi_set_country = _kernel_api.wifi_apis->wifi_set_country;
|
||||
mico_api.switch_active_firmrware = NULL;
|
||||
mico_api.last_reset_reason = _kernel_api.os_apis->last_reset_reason;
|
||||
mico_api.aon_write = _kernel_api.os_apis->aon_write;
|
||||
mico_api.aon_read = _kernel_api.os_apis->aon_read;
|
||||
mico_api.ssl_get_fd = _kernel_api.ssl_crypto_apis->ssl_get_fd;
|
||||
mico_api.get_random_sequence = _kernel_api.os_apis->get_random_sequence;
|
||||
mico_api.ssl_set_loggingcb = _kernel_api.ssl_crypto_apis->ssl_loggingcb;
|
||||
mico_api.wlan_inject_frame = _kernel_api.wifi_apis->wlan_inject_frame;
|
||||
mico_api.wlan_rx_mgmt_indication = NULL;
|
||||
mico_api.wlan_remain_on_channel = NULL;
|
||||
mico_api.wifi_bridge_mode_enable = NULL;
|
||||
mico_api.wifi_bridge_mode_disable = NULL;
|
||||
mico_api.send_easylink_minus = _kernel_api.wifi_apis->send_easylink_minus;
|
||||
mico_api.ssl_socket = (int(*)(void*))(_kernel_api.ssl_crypto_apis->ssl_get_fd);
|
||||
|
||||
mico_api.i2c_apis = _kernel_api.i2c_apis;
|
||||
mico_api.spi_apis = _kernel_api.spi_apis;
|
||||
mico_api.pwm_apis = _kernel_api.pwm_apis;
|
||||
mico_api.wdg_apis = _kernel_api.wdg_apis;
|
||||
mico_api.adc_apis = _kernel_api.adc_apis;
|
||||
mico_api.gtimer_apis = _kernel_api.gtimer_apis;
|
||||
|
||||
return &mico_api;
|
||||
}
|
||||
|
||||
int debug_putchar(char *ch, int len)
|
||||
{
|
||||
return _kernel_api.os_apis->debug_putchar(ch, len);
|
||||
}
|
||||
|
||||
int debug_gettchar(char *ch)
|
||||
{
|
||||
return _kernel_api.os_apis->debug_getchar(ch);
|
||||
}
|
||||
|
||||
int mico_wlan_monitor_no_easylink(void)
|
||||
{
|
||||
return _kernel_api.wifi_apis->mico_wlan_monitor_no_easylink();
|
||||
}
|
||||
|
||||
int wlan_rx_mgnt_set(int enable, mgnt_handler_t cb)
|
||||
{
|
||||
return _kernel_api.wifi_apis->wlan_rx_mgnt_set(enable, cb);
|
||||
}
|
||||
|
||||
void autoconfig_start(int seconds, int mode)
|
||||
{
|
||||
_kernel_api.wifi_apis->autoconfig_start(seconds, mode);
|
||||
}
|
||||
|
||||
void wlan_set_softap_tdma(int value)
|
||||
{
|
||||
_kernel_api.wifi_apis->wlan_set_softap_tdma(value);
|
||||
}
|
||||
|
||||
int wifi_off_fastly(void)
|
||||
{
|
||||
return _kernel_api.wifi_apis->wifi_off_fastly();
|
||||
}
|
||||
|
||||
int OpenEasylink_softap(int timeout, char *ssid, char*key, int channel)
|
||||
{
|
||||
return _kernel_api.wifi_apis->OpenEasylink_softap(timeout, ssid, key, channel);
|
||||
}
|
||||
|
||||
void ssl_set_ecc(int enable)
|
||||
{
|
||||
_kernel_api.ssl_crypto_apis->ssl_set_ecc(enable);
|
||||
}
|
||||
|
||||
/* return 1=success; 0=fail*/
|
||||
int disable_log_uart(void)
|
||||
{
|
||||
return _kernel_api.uart_apis->disable_log_uart();
|
||||
}
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,257 +1,263 @@
|
||||
enum {
|
||||
API_VERSION_V1 = 1,
|
||||
API_VERSION_MAX,
|
||||
};
|
||||
|
||||
typedef void* mico_event;
|
||||
typedef void (*ssl_log_cb)(const int logLevel, const char *const logMessage);
|
||||
typedef struct Md5 {
|
||||
uint32_t buffLen; /* length in bytes */
|
||||
uint32_t loLen; /* length in bytes */
|
||||
uint32_t hiLen; /* length in bytes */
|
||||
uint32_t buffer[MD5_BLOCK_SIZE / sizeof(uint32_t)];
|
||||
uint32_t digest[MD5_DIGEST_SIZE / sizeof(uint32_t)];
|
||||
} Md5;
|
||||
|
||||
|
||||
typedef void (*mgnt_handler_t)(char *buf, int buf_len);
|
||||
|
||||
typedef struct {
|
||||
/* OS Layer*/
|
||||
int (*system_config)(int type, void *value);/* system configuration */
|
||||
int (*mxchipInit)();
|
||||
OSStatus (*mico_rtos_create_thread)( mico_thread_t* thread, uint8_t priority, const char* name, mico_thread_function_t function, uint32_t stack_size, uint32_t arg );
|
||||
OSStatus (*mico_rtos_delete_thread)( mico_thread_t* thread );
|
||||
void (*mico_rtos_suspend_thread)(mico_thread_t* thread);
|
||||
void (*mico_rtos_suspend_all_thread)(void);
|
||||
long (*mico_rtos_resume_all_thread)(void);
|
||||
OSStatus (*mico_rtos_thread_join)( mico_thread_t* thread );
|
||||
OSStatus (*mico_rtos_thread_force_awake)( mico_thread_t* thread );
|
||||
bool (*mico_rtos_is_current_thread)( mico_thread_t* thread );
|
||||
void (*mico_thread_sleep)(uint32_t seconds);
|
||||
void (*mico_thread_msleep)(uint32_t milliseconds);
|
||||
OSStatus (*mico_rtos_init_semaphore)( mico_semaphore_t* semaphore, int count );
|
||||
OSStatus (*mico_rtos_set_semaphore)( mico_semaphore_t* semaphore );
|
||||
OSStatus (*mico_rtos_get_semaphore)( mico_semaphore_t* semaphore, uint32_t timeout_ms );
|
||||
OSStatus (*mico_rtos_deinit_semaphore)( mico_semaphore_t* semaphore );
|
||||
OSStatus (*mico_rtos_init_mutex)( mico_mutex_t* mutex );
|
||||
OSStatus (*mico_rtos_lock_mutex)( mico_mutex_t* mutex );
|
||||
OSStatus (*mico_rtos_unlock_mutex)( mico_mutex_t* mutex );
|
||||
OSStatus (*mico_rtos_deinit_mutex)( mico_mutex_t* mutex );
|
||||
OSStatus (*mico_rtos_init_queue)( mico_queue_t* queue, const char* name, uint32_t message_size, uint32_t number_of_messages );
|
||||
OSStatus (*mico_rtos_push_to_queue)( mico_queue_t* queue, void* message, uint32_t timeout_ms );
|
||||
OSStatus (*mico_rtos_pop_from_queue)( mico_queue_t* queue, void* message, uint32_t timeout_ms );
|
||||
OSStatus (*mico_rtos_deinit_queue)( mico_queue_t* queue );
|
||||
bool (*mico_rtos_is_queue_empty)( mico_queue_t* queue );
|
||||
bool (*mico_rtos_is_queue_full)( mico_queue_t* queue );
|
||||
uint32_t (*mico_get_time)(void);
|
||||
OSStatus (*mico_init_timer)( mico_timer_t* timer, uint32_t time_ms, timer_handler_t function, void* arg );
|
||||
OSStatus (*mico_start_timer)( mico_timer_t* timer );
|
||||
OSStatus (*mico_stop_timer)( mico_timer_t* timer );
|
||||
OSStatus (*mico_reload_timer)( mico_timer_t* timer );
|
||||
OSStatus (*mico_deinit_timer)( mico_timer_t* timer );
|
||||
bool (*mico_is_timer_running)( mico_timer_t* timer );
|
||||
int (*mico_create_event_fd)(mico_event handle);
|
||||
int (*mico_delete_event_fd)(int fd);
|
||||
|
||||
/* memory management*/
|
||||
struct mxchip_mallinfo* (*mico_memory_info)(void);
|
||||
void* (*malloc)(size_t size); // malloc
|
||||
void* (*realloc)(void* pv, size_t size); // realloc
|
||||
void (*free)(void* pv); //free
|
||||
void* (*calloc)(size_t nmemb, size_t size); // calloc
|
||||
void (*heap_insert)(uint8_t *pv, int len);
|
||||
|
||||
void (*get_random_sequence)(unsigned char *buf, unsigned int size);
|
||||
int (*last_reset_reason)(void);
|
||||
int (*aon_write)( uint32_t offset, uint8_t* in ,uint32_t len);
|
||||
int (*aon_read )( uint32_t offset, uint8_t* out, uint32_t len);
|
||||
|
||||
/* uitls */
|
||||
int (*debug_putchar)(char *ch, int len);
|
||||
int (*debug_getchar)(char *ch);
|
||||
void (*MicoSystemReboot)( void );
|
||||
|
||||
struct tm* (*localtime)(const time_t * time);
|
||||
char * (*asctime)(const struct tm *tm);
|
||||
} os_api_v1_t;
|
||||
|
||||
typedef struct {
|
||||
/* SSL */
|
||||
void (*ssl_set_cert)(const char *_cert_pem, const char *private_key_pem);
|
||||
void* (*ssl_connect)(int fd, int calen, char*ca, int *errno);
|
||||
void* (*ssl_accept)(int fd);
|
||||
int (*ssl_send)(void* ssl, char *data, int len);
|
||||
int (*ssl_recv)(void* ssl, char *data, int len);
|
||||
int (*ssl_close)(void* ssl);
|
||||
void (*set_ssl_client_version)(int version);
|
||||
|
||||
int (*ssl_pending)(void* ssl);
|
||||
int (*ssl_get_error)(void* ssl, int ret);
|
||||
void (*ssl_set_using_nonblock)(void* ssl, int nonblock);
|
||||
int (*ssl_get_fd)(const void* ssl);
|
||||
int (*ssl_loggingcb)(ssl_log_cb f);
|
||||
|
||||
/*crypto*/
|
||||
void (*InitMd5)(Md5*md5);
|
||||
void (*Md5Update)(Md5* md5, const uint8_t* data, uint32_t len);
|
||||
void (*Md5Final)(Md5* md5, uint8_t* hash);
|
||||
int (*Md5Hash)(const uint8_t* data, uint32_t len, uint8_t* hash);
|
||||
void (*AesEncryptDirect)(Aes* aes, uint8_t* out, const uint8_t* in);
|
||||
void (*AesDecryptDirect)(Aes* aes, uint8_t* out, const uint8_t* in);
|
||||
int (*AesSetKeyDirect)(Aes* aes, const uint8_t* key, uint32_t len,
|
||||
const uint8_t* iv, int dir);
|
||||
int (*aes_encrypt)(int sz, const char * key, const char * in, char * out);
|
||||
int (*aes_decrypt)(int sz, const char * key, const char * in, char * out);
|
||||
int (*AesSetKey)(Aes* aes, const uint8_t* key, uint32_t len,
|
||||
const uint8_t* iv, int dir);
|
||||
int (*AesSetIV)(Aes* aes, const uint8_t* iv);
|
||||
int (*AesCbcEncrypt)(Aes* aes, uint8_t* out,
|
||||
const uint8_t* in, uint32_t sz);
|
||||
int (*AesCbcDecrypt)(Aes* aes, uint8_t* out,
|
||||
const uint8_t* in, uint32_t sz);
|
||||
void* (*ssl_nonblock_connect)(int fd, int calen, char*ca, int *errno, int timeout);
|
||||
void (*ssl_set_client_cert)(const char *_cert_pem, const char *private_key_pem);
|
||||
void* (*ssl_connect_sni)(int fd, int calen, char*ca, char *sni_servername, int *errno);
|
||||
} ssl_crypto_api_v1_t;
|
||||
|
||||
typedef struct {
|
||||
/* WIFI MGR */
|
||||
int (*wlan_get_mac_address)(unsigned char *dest);
|
||||
int (*wlan_get_mac_address_by_interface)(wlan_if_t wlan_if, unsigned char *dest);
|
||||
int (*wlan_driver_version)( char* version, int length );
|
||||
OSStatus (*micoWlanStart)(network_InitTypeDef_st* inNetworkInitPara);
|
||||
OSStatus (*micoWlanStartAdv)(network_InitTypeDef_adv_st* inNetworkInitParaAdv);
|
||||
OSStatus (*micoWlanGetIPStatus)(IPStatusTypedef *outNetpara, WiFi_Interface inInterface);
|
||||
OSStatus (*micoWlanGetLinkStatus)(LinkStatusTypeDef *outStatus);
|
||||
void (*micoWlanStartScan)(void);
|
||||
void (*micoWlanStartScanAdv)(void);
|
||||
OSStatus (*micoWlanPowerOff)(void);
|
||||
OSStatus (*micoWlanPowerOn)(void);
|
||||
OSStatus (*micoWlanSuspend)(void);
|
||||
OSStatus (*micoWlanSuspendStation)(void);
|
||||
OSStatus (*micoWlanSuspendSoftAP)(void);
|
||||
OSStatus (*micoWlanStartEasyLink)(int inTimeout);
|
||||
OSStatus (*micoWlanStopEasyLink)(void);
|
||||
void (*micoWlanEnablePowerSave)(void);
|
||||
void (*micoWlanDisablePowerSave)(void);
|
||||
void (*wifimgr_debug_enable)(bool enable);
|
||||
int (*mico_wlan_monitor_rx_type)(int type);
|
||||
int (*mico_wlan_start_monitor)(void);
|
||||
int (*mico_wlan_stop_monitor)(void);
|
||||
int (*mico_wlan_set_channel)(int channel);
|
||||
void (*mico_wlan_register_monitor_cb)(monitor_cb_t fn);
|
||||
void (*wlan_set_channel)(int channel);
|
||||
int (*mxchip_active_scan)(char*ssid, int is_adv);
|
||||
int (*send_easylink_minus)(uint32_t ip, char *ssid, char *key) ;
|
||||
int (*mico_wlan_get_channel)(void);
|
||||
OSStatus (*wifi_manage_custom_ie_add)(wlan_if_t wlan_if, uint8_t *custom_ie, uint32_t len);
|
||||
OSStatus (*wifi_manage_custom_ie_delete)(wlan_if_t wlan_if);
|
||||
int (*wlan_inject_frame)(const uint8_t *buff, size_t len);
|
||||
int (*mico_wlan_monitor_no_easylink)(void);
|
||||
int (*wifi_set_country)(int country_code);
|
||||
int (*wlan_rx_mgnt_set)(int enable, mgnt_handler_t cb);
|
||||
void (*autoconfig_start)(int seconds, int mode);
|
||||
} wifi_api_v1_t;
|
||||
|
||||
typedef struct {
|
||||
/* CLI APIs */
|
||||
int (*cli_init)(void);
|
||||
int (*cli_register_command)(const struct cli_command *command);
|
||||
int (*cli_unregister_command)(const struct cli_command *command);
|
||||
void (*wifistate_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*wifidebug_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*wifiscan_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*ifconfig_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*arp_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*ping_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*dns_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*task_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*socket_show_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*memory_show_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*memory_dump_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*memory_set_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*memp_dump_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*driver_state_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*iperf_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
} cli_api_v1_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
mico_logic_partition_t* (*MicoFlashGetInfo)( mico_partition_t inPartition );
|
||||
OSStatus (*MicoFlashErase)(mico_partition_t inPartition, uint32_t off_set, uint32_t size);
|
||||
OSStatus (*MicoFlashWrite)( mico_partition_t inPartition, volatile uint32_t* off_set, uint8_t* inBuffer ,uint32_t inBufferLength);
|
||||
OSStatus (*MicoFlashRead)( mico_partition_t inPartition, volatile uint32_t* off_set, uint8_t* outBuffer, uint32_t inBufferLength);
|
||||
OSStatus (*MicoFlashEnableSecurity)( mico_partition_t partition, uint32_t off_set, uint32_t size );
|
||||
} flash_api_t;
|
||||
|
||||
typedef struct {
|
||||
OSStatus (*MicoGpioInitialize)( mico_gpio_t gpio, mico_gpio_config_t configuration );
|
||||
OSStatus (*MicoGpioFinalize)( mico_gpio_t gpio );
|
||||
OSStatus (*MicoGpioOutputHigh)( mico_gpio_t gpio );
|
||||
OSStatus (*MicoGpioOutputLow)( mico_gpio_t gpio );
|
||||
OSStatus (*MicoGpioOutputTrigger)( mico_gpio_t gpio );
|
||||
bool (*MicoGpioInputGet)( mico_gpio_t gpio );
|
||||
OSStatus (*MicoGpioEnableIRQ)( mico_gpio_t gpio, mico_gpio_irq_trigger_t trigger, mico_gpio_irq_handler_t handler, void* arg );
|
||||
OSStatus (*MicoGpioDisableIRQ)( mico_gpio_t gpio );
|
||||
} gpio_api_t;
|
||||
|
||||
typedef struct {
|
||||
OSStatus (*MicoUartInitialize)( mico_uart_t uart, const mico_uart_config_t* config, ring_buffer_t* optional_rx_buffer );
|
||||
OSStatus (*MicoUartFinalize)( mico_uart_t uart );
|
||||
OSStatus (*MicoUartSend)( mico_uart_t uart, const void* data, uint32_t size );
|
||||
OSStatus (*MicoUartRecv)( mico_uart_t uart, void* data, uint32_t size, uint32_t timeout );
|
||||
uint32_t (*MicoUartGetLengthInBuffer)( mico_uart_t uart );
|
||||
void (*MicoUartPinRedirect)(mico_uart_t uart);
|
||||
} uart_api_t;
|
||||
|
||||
typedef struct {
|
||||
void (*MicoRtcInitialize)(void);
|
||||
OSStatus (*MicoRtcGetTime)(mico_rtc_time_t *time);
|
||||
OSStatus (*MicoRtcSetTime)(mico_rtc_time_t *time);
|
||||
} rtc_api_t;
|
||||
|
||||
typedef struct {
|
||||
/* Power management*/
|
||||
int (*pm_mcu_state)(power_state_t state, uint32_t time_dur);
|
||||
int (*pm_wakeup_source)();
|
||||
void (*wifi_off_mcu_standby)(uint32_t seconds);
|
||||
void (*MicoMcuPowerSaveConfig)( int enable );
|
||||
} power_save_api_t;
|
||||
|
||||
typedef os_api_v1_t os_api_t;
|
||||
typedef ssl_crypto_api_v1_t ssl_crypto_api_t;
|
||||
typedef wifi_api_v1_t wifi_api_t;
|
||||
typedef cli_api_v1_t cli_api_t;
|
||||
|
||||
/* API type define */
|
||||
typedef struct
|
||||
{
|
||||
os_api_t *os_apis;
|
||||
lwip_api_t *lwip_apis;
|
||||
ssl_crypto_api_t *ssl_crypto_apis;
|
||||
wifi_api_t *wifi_apis;
|
||||
cli_api_t *cli_apis;
|
||||
|
||||
flash_api_t *flash_apis;
|
||||
gpio_api_t *gpio_apis;
|
||||
uart_api_t *uart_apis;
|
||||
i2c_api_t *i2c_apis;
|
||||
spi_api_t *spi_apis;
|
||||
pwm_api_t *pwm_apis;
|
||||
rtc_api_t *rtc_apis;
|
||||
wdg_api_t *wdg_apis;
|
||||
adc_api_t *adc_apis;
|
||||
power_save_api_t *ps_apis;
|
||||
} kernel_api_v1_t;
|
||||
|
||||
typedef kernel_api_v1_t kernel_api_t;
|
||||
|
||||
typedef struct new_mico_api_struct
|
||||
{
|
||||
char *library_version;
|
||||
|
||||
int (*mico_api_get)(int version, void *kernel_apis);
|
||||
} new_mico_api_t;
|
||||
|
||||
mico_api_t *moc_adapter(new_mico_api_t *new_mico_api);
|
||||
enum {
|
||||
API_VERSION_V1 = 1,
|
||||
API_VERSION_MAX,
|
||||
};
|
||||
|
||||
typedef void* mico_event;
|
||||
typedef void (*ssl_log_cb)(const int logLevel, const char *const logMessage);
|
||||
typedef struct Md5 {
|
||||
uint32_t buffLen; /* length in bytes */
|
||||
uint32_t loLen; /* length in bytes */
|
||||
uint32_t hiLen; /* length in bytes */
|
||||
uint32_t buffer[MD5_BLOCK_SIZE / sizeof(uint32_t)];
|
||||
uint32_t digest[MD5_DIGEST_SIZE / sizeof(uint32_t)];
|
||||
} Md5;
|
||||
|
||||
|
||||
typedef void (*mgnt_handler_t)(char *buf, int buf_len);
|
||||
|
||||
typedef struct {
|
||||
/* OS Layer*/
|
||||
int (*system_config)(int type, void *value);/* system configuration */
|
||||
int (*mxchipInit)();
|
||||
OSStatus (*mico_rtos_create_thread)( mico_thread_t* thread, uint8_t priority, const char* name, mico_thread_function_t function, uint32_t stack_size, uint32_t arg );
|
||||
OSStatus (*mico_rtos_delete_thread)( mico_thread_t* thread );
|
||||
void (*mico_rtos_suspend_thread)(mico_thread_t* thread);
|
||||
void (*mico_rtos_suspend_all_thread)(void);
|
||||
long (*mico_rtos_resume_all_thread)(void);
|
||||
OSStatus (*mico_rtos_thread_join)( mico_thread_t* thread );
|
||||
OSStatus (*mico_rtos_thread_force_awake)( mico_thread_t* thread );
|
||||
bool (*mico_rtos_is_current_thread)( mico_thread_t* thread );
|
||||
void (*mico_thread_sleep)(uint32_t seconds);
|
||||
void (*mico_thread_msleep)(uint32_t milliseconds);
|
||||
OSStatus (*mico_rtos_init_semaphore)( mico_semaphore_t* semaphore, int count );
|
||||
OSStatus (*mico_rtos_set_semaphore)( mico_semaphore_t* semaphore );
|
||||
OSStatus (*mico_rtos_get_semaphore)( mico_semaphore_t* semaphore, uint32_t timeout_ms );
|
||||
OSStatus (*mico_rtos_deinit_semaphore)( mico_semaphore_t* semaphore );
|
||||
OSStatus (*mico_rtos_init_mutex)( mico_mutex_t* mutex );
|
||||
OSStatus (*mico_rtos_lock_mutex)( mico_mutex_t* mutex );
|
||||
OSStatus (*mico_rtos_unlock_mutex)( mico_mutex_t* mutex );
|
||||
OSStatus (*mico_rtos_deinit_mutex)( mico_mutex_t* mutex );
|
||||
OSStatus (*mico_rtos_init_queue)( mico_queue_t* queue, const char* name, uint32_t message_size, uint32_t number_of_messages );
|
||||
OSStatus (*mico_rtos_push_to_queue)( mico_queue_t* queue, void* message, uint32_t timeout_ms );
|
||||
OSStatus (*mico_rtos_pop_from_queue)( mico_queue_t* queue, void* message, uint32_t timeout_ms );
|
||||
OSStatus (*mico_rtos_deinit_queue)( mico_queue_t* queue );
|
||||
bool (*mico_rtos_is_queue_empty)( mico_queue_t* queue );
|
||||
bool (*mico_rtos_is_queue_full)( mico_queue_t* queue );
|
||||
uint32_t (*mico_get_time)(void);
|
||||
OSStatus (*mico_init_timer)( mico_timer_t* timer, uint32_t time_ms, timer_handler_t function, void* arg );
|
||||
OSStatus (*mico_start_timer)( mico_timer_t* timer );
|
||||
OSStatus (*mico_stop_timer)( mico_timer_t* timer );
|
||||
OSStatus (*mico_reload_timer)( mico_timer_t* timer );
|
||||
OSStatus (*mico_deinit_timer)( mico_timer_t* timer );
|
||||
bool (*mico_is_timer_running)( mico_timer_t* timer );
|
||||
int (*mico_create_event_fd)(mico_event handle);
|
||||
int (*mico_delete_event_fd)(int fd);
|
||||
|
||||
/* memory management*/
|
||||
struct mxchip_mallinfo* (*mico_memory_info)(void);
|
||||
void* (*malloc)(size_t size); // malloc
|
||||
void* (*realloc)(void* pv, size_t size); // realloc
|
||||
void (*free)(void* pv); //free
|
||||
void* (*calloc)(size_t nmemb, size_t size); // calloc
|
||||
void (*heap_insert)(uint8_t *pv, int len);
|
||||
|
||||
void (*get_random_sequence)(unsigned char *buf, unsigned int size);
|
||||
int (*last_reset_reason)(void);
|
||||
int (*aon_write)( uint32_t offset, uint8_t* in ,uint32_t len);
|
||||
int (*aon_read )( uint32_t offset, uint8_t* out, uint32_t len);
|
||||
|
||||
/* uitls */
|
||||
int (*debug_putchar)(char *ch, int len);
|
||||
int (*debug_getchar)(char *ch);
|
||||
void (*MicoSystemReboot)( void );
|
||||
|
||||
struct tm* (*localtime)(const time_t * time);
|
||||
char * (*asctime)(const struct tm *tm);
|
||||
} os_api_v1_t;
|
||||
|
||||
typedef struct {
|
||||
/* SSL */
|
||||
void (*ssl_set_cert)(const char *_cert_pem, const char *private_key_pem);
|
||||
void* (*ssl_connect)(int fd, int calen, char*ca, int *errno);
|
||||
void* (*ssl_accept)(int fd);
|
||||
int (*ssl_send)(void* ssl, char *data, int len);
|
||||
int (*ssl_recv)(void* ssl, char *data, int len);
|
||||
int (*ssl_close)(void* ssl);
|
||||
void (*set_ssl_client_version)(int version);
|
||||
|
||||
int (*ssl_pending)(void* ssl);
|
||||
int (*ssl_get_error)(void* ssl, int ret);
|
||||
void (*ssl_set_using_nonblock)(void* ssl, int nonblock);
|
||||
int (*ssl_get_fd)(const void* ssl);
|
||||
int (*ssl_loggingcb)(ssl_log_cb f);
|
||||
|
||||
/*crypto*/
|
||||
void (*InitMd5)(Md5*md5);
|
||||
void (*Md5Update)(Md5* md5, const uint8_t* data, uint32_t len);
|
||||
void (*Md5Final)(Md5* md5, uint8_t* hash);
|
||||
int (*Md5Hash)(const uint8_t* data, uint32_t len, uint8_t* hash);
|
||||
void (*AesEncryptDirect)(Aes* aes, uint8_t* out, const uint8_t* in);
|
||||
void (*AesDecryptDirect)(Aes* aes, uint8_t* out, const uint8_t* in);
|
||||
int (*AesSetKeyDirect)(Aes* aes, const uint8_t* key, uint32_t len,
|
||||
const uint8_t* iv, int dir);
|
||||
int (*aes_encrypt)(int sz, const char * key, const char * in, char * out);
|
||||
int (*aes_decrypt)(int sz, const char * key, const char * in, char * out);
|
||||
int (*AesSetKey)(Aes* aes, const uint8_t* key, uint32_t len,
|
||||
const uint8_t* iv, int dir);
|
||||
int (*AesSetIV)(Aes* aes, const uint8_t* iv);
|
||||
int (*AesCbcEncrypt)(Aes* aes, uint8_t* out,
|
||||
const uint8_t* in, uint32_t sz);
|
||||
int (*AesCbcDecrypt)(Aes* aes, uint8_t* out,
|
||||
const uint8_t* in, uint32_t sz);
|
||||
void* (*ssl_nonblock_connect)(int fd, int calen, char*ca, int *errno, int timeout);
|
||||
void (*ssl_set_client_cert)(const char *_cert_pem, const char *private_key_pem);
|
||||
void* (*ssl_connect_sni)(int fd, int calen, char*ca, char *sni_servername, int *errno);
|
||||
void (*ssl_set_ecc)(int enable);
|
||||
} ssl_crypto_api_v1_t;
|
||||
|
||||
typedef struct {
|
||||
/* WIFI MGR */
|
||||
int (*wlan_get_mac_address)(unsigned char *dest);
|
||||
int (*wlan_get_mac_address_by_interface)(wlan_if_t wlan_if, unsigned char *dest);
|
||||
int (*wlan_driver_version)( char* version, int length );
|
||||
OSStatus (*micoWlanStart)(network_InitTypeDef_st* inNetworkInitPara);
|
||||
OSStatus (*micoWlanStartAdv)(network_InitTypeDef_adv_st* inNetworkInitParaAdv);
|
||||
OSStatus (*micoWlanGetIPStatus)(IPStatusTypedef *outNetpara, WiFi_Interface inInterface);
|
||||
OSStatus (*micoWlanGetLinkStatus)(LinkStatusTypeDef *outStatus);
|
||||
void (*micoWlanStartScan)(void);
|
||||
void (*micoWlanStartScanAdv)(void);
|
||||
OSStatus (*micoWlanPowerOff)(void);
|
||||
OSStatus (*micoWlanPowerOn)(void);
|
||||
OSStatus (*micoWlanSuspend)(void);
|
||||
OSStatus (*micoWlanSuspendStation)(void);
|
||||
OSStatus (*micoWlanSuspendSoftAP)(void);
|
||||
OSStatus (*micoWlanStartEasyLink)(int inTimeout);
|
||||
OSStatus (*micoWlanStopEasyLink)(void);
|
||||
void (*micoWlanEnablePowerSave)(void);
|
||||
void (*micoWlanDisablePowerSave)(void);
|
||||
void (*wifimgr_debug_enable)(bool enable);
|
||||
int (*mico_wlan_monitor_rx_type)(int type);
|
||||
int (*mico_wlan_start_monitor)(void);
|
||||
int (*mico_wlan_stop_monitor)(void);
|
||||
int (*mico_wlan_set_channel)(int channel);
|
||||
void (*mico_wlan_register_monitor_cb)(monitor_cb_t fn);
|
||||
void (*wlan_set_channel)(int channel);
|
||||
int (*mxchip_active_scan)(char*ssid, int is_adv);
|
||||
int (*send_easylink_minus)(uint32_t ip, char *ssid, char *key) ;
|
||||
int (*mico_wlan_get_channel)(void);
|
||||
OSStatus (*wifi_manage_custom_ie_add)(wlan_if_t wlan_if, uint8_t *custom_ie, uint32_t len);
|
||||
OSStatus (*wifi_manage_custom_ie_delete)(wlan_if_t wlan_if);
|
||||
int (*wlan_inject_frame)(const uint8_t *buff, size_t len);
|
||||
int (*mico_wlan_monitor_no_easylink)(void);
|
||||
int (*wifi_set_country)(int country_code);
|
||||
int (*wlan_rx_mgnt_set)(int enable, mgnt_handler_t cb);
|
||||
void (*autoconfig_start)(int seconds, int mode);
|
||||
void (*wlan_set_softap_tdma)(int value);
|
||||
int (*wifi_off_fastly)(void);
|
||||
int (*OpenEasylink_softap)(int timeout, char *ssid, char*key, int channel);
|
||||
} wifi_api_v1_t;
|
||||
|
||||
typedef struct {
|
||||
/* CLI APIs */
|
||||
int (*cli_init)(void);
|
||||
int (*cli_register_command)(const struct cli_command *command);
|
||||
int (*cli_unregister_command)(const struct cli_command *command);
|
||||
void (*wifistate_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*wifidebug_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*wifiscan_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*ifconfig_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*arp_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*ping_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*dns_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*task_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*socket_show_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*memory_show_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*memory_dump_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*memory_set_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*memp_dump_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*driver_state_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
void (*iperf_Command)(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv);
|
||||
} cli_api_v1_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
mico_logic_partition_t* (*MicoFlashGetInfo)( mico_partition_t inPartition );
|
||||
OSStatus (*MicoFlashErase)(mico_partition_t inPartition, uint32_t off_set, uint32_t size);
|
||||
OSStatus (*MicoFlashWrite)( mico_partition_t inPartition, volatile uint32_t* off_set, uint8_t* inBuffer ,uint32_t inBufferLength);
|
||||
OSStatus (*MicoFlashRead)( mico_partition_t inPartition, volatile uint32_t* off_set, uint8_t* outBuffer, uint32_t inBufferLength);
|
||||
OSStatus (*MicoFlashEnableSecurity)( mico_partition_t partition, uint32_t off_set, uint32_t size );
|
||||
} flash_api_t;
|
||||
|
||||
typedef struct {
|
||||
OSStatus (*MicoGpioInitialize)( mico_gpio_t gpio, mico_gpio_config_t configuration );
|
||||
OSStatus (*MicoGpioFinalize)( mico_gpio_t gpio );
|
||||
OSStatus (*MicoGpioOutputHigh)( mico_gpio_t gpio );
|
||||
OSStatus (*MicoGpioOutputLow)( mico_gpio_t gpio );
|
||||
OSStatus (*MicoGpioOutputTrigger)( mico_gpio_t gpio );
|
||||
bool (*MicoGpioInputGet)( mico_gpio_t gpio );
|
||||
OSStatus (*MicoGpioEnableIRQ)( mico_gpio_t gpio, mico_gpio_irq_trigger_t trigger, mico_gpio_irq_handler_t handler, void* arg );
|
||||
OSStatus (*MicoGpioDisableIRQ)( mico_gpio_t gpio );
|
||||
} gpio_api_t;
|
||||
|
||||
typedef struct {
|
||||
OSStatus (*MicoUartInitialize)( mico_uart_t uart, const mico_uart_config_t* config, ring_buffer_t* optional_rx_buffer );
|
||||
OSStatus (*MicoUartFinalize)( mico_uart_t uart );
|
||||
OSStatus (*MicoUartSend)( mico_uart_t uart, const void* data, uint32_t size );
|
||||
OSStatus (*MicoUartRecv)( mico_uart_t uart, void* data, uint32_t size, uint32_t timeout );
|
||||
uint32_t (*MicoUartGetLengthInBuffer)( mico_uart_t uart );
|
||||
void (*MicoUartPinRedirect)(mico_uart_t uart);
|
||||
int (*disable_log_uart)(void);
|
||||
} uart_api_t;
|
||||
|
||||
typedef struct {
|
||||
void (*MicoRtcInitialize)(void);
|
||||
OSStatus (*MicoRtcGetTime)(mico_rtc_time_t *time);
|
||||
OSStatus (*MicoRtcSetTime)(mico_rtc_time_t *time);
|
||||
} rtc_api_t;
|
||||
|
||||
typedef struct {
|
||||
/* Power management*/
|
||||
int (*pm_mcu_state)(power_state_t state, uint32_t time_dur);
|
||||
int (*pm_wakeup_source)(uint8_t wake_source);
|
||||
void (*wifi_off_mcu_standby)(uint32_t seconds);
|
||||
void (*MicoMcuPowerSaveConfig)( int enable );
|
||||
} power_save_api_t;
|
||||
|
||||
typedef os_api_v1_t os_api_t;
|
||||
typedef ssl_crypto_api_v1_t ssl_crypto_api_t;
|
||||
typedef wifi_api_v1_t wifi_api_t;
|
||||
typedef cli_api_v1_t cli_api_t;
|
||||
|
||||
/* API type define */
|
||||
typedef struct
|
||||
{
|
||||
os_api_t *os_apis;
|
||||
lwip_api_t *lwip_apis;
|
||||
ssl_crypto_api_t *ssl_crypto_apis;
|
||||
wifi_api_t *wifi_apis;
|
||||
cli_api_t *cli_apis;
|
||||
|
||||
flash_api_t *flash_apis;
|
||||
gpio_api_t *gpio_apis;
|
||||
uart_api_t *uart_apis;
|
||||
i2c_api_t *i2c_apis;
|
||||
spi_api_t *spi_apis;
|
||||
pwm_api_t *pwm_apis;
|
||||
rtc_api_t *rtc_apis;
|
||||
wdg_api_t *wdg_apis;
|
||||
adc_api_t *adc_apis;
|
||||
power_save_api_t *ps_apis;
|
||||
gtimer_api_t *gtimer_apis;
|
||||
} kernel_api_v1_t;
|
||||
|
||||
typedef kernel_api_v1_t kernel_api_t;
|
||||
|
||||
typedef struct new_mico_api_struct
|
||||
{
|
||||
char *library_version;
|
||||
|
||||
int (*mico_api_get)(int version, void *kernel_apis);
|
||||
} new_mico_api_t;
|
||||
|
||||
mico_api_t *moc_adapter(new_mico_api_t *new_mico_api);
|
||||
|
||||
@@ -1,185 +1,185 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @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 "platform_cmsis.h"
|
||||
|
||||
|
||||
#include "mico_rtos.h"
|
||||
#include "RingBufferUtils.h"
|
||||
|
||||
//#include "lowlevel_drivers.h"
|
||||
//#include "boot_flags.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* UART flow control for driver
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FLOW_CONTROL_DISABLED_DRV,
|
||||
FLOW_CONTROL_CTS_DRV,
|
||||
FLOW_CONTROL_RTS_DRV,
|
||||
FLOW_CONTROL_CTS_RTS_DRV
|
||||
} platform_uart_driver_flow_control_t;
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unimplemented;
|
||||
} 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;
|
||||
mico_bool_t initialized;
|
||||
} platform_spi_driver_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unimplemented;
|
||||
} platform_spi_slave_driver_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unimplemented;
|
||||
} platform_i2c_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mico_mutex_t i2c_mutex;
|
||||
} platform_i2c_driver_t;
|
||||
|
||||
typedef void (* wakeup_irq_handler_t)(void *arg);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t port_id;
|
||||
} platform_uart_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t id;
|
||||
ring_buffer_t* rx_ring_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;
|
||||
platform_uart_driver_flow_control_t flow_control;
|
||||
} platform_uart_driver_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t flash_type;
|
||||
uint32_t flash_start_addr;
|
||||
uint32_t flash_length;
|
||||
} 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
|
||||
******************************************************/
|
||||
//int get_passive_firmware(void);
|
||||
//int part_write_layout(void);
|
||||
|
||||
|
||||
|
||||
//OSStatus platform_gpio_irq_manager_init ( void );
|
||||
//uint8_t platform_gpio_get_port_number ( platform_gpio_port_t* gpio_port );
|
||||
//OSStatus platform_gpio_enable_clock ( const platform_gpio_t* gpio );
|
||||
//OSStatus platform_gpio_set_alternate_function( platform_gpio_port_t* gpio_port, uint8_t pin_number, GPIOOType_TypeDef output_type, GPIOPuPd_TypeDef pull_up_down_type, uint8_t alternation_function );
|
||||
//
|
||||
//OSStatus platform_mcu_powersave_init ( void );
|
||||
//
|
||||
//OSStatus platform_rtc_init ( void );
|
||||
//OSStatus platform_rtc_enter_powersave ( void );
|
||||
//OSStatus platform_rtc_abort_powersave ( void );
|
||||
//OSStatus platform_rtc_exit_powersave ( uint32_t requested_sleep_time, uint32_t *cpu_sleep_time );
|
||||
//
|
||||
//uint8_t platform_uart_get_port_number ( platform_uart_port_t* uart );
|
||||
//void platform_uart_irq ( platform_uart_driver_t* driver );
|
||||
//void platform_uart_tx_dma_irq ( platform_uart_driver_t* driver );
|
||||
//void platform_uart_rx_dma_irq ( platform_uart_driver_t* driver );
|
||||
//
|
||||
//uint8_t platform_spi_get_port_number ( platform_spi_port_t* spi );
|
||||
|
||||
#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 "platform_cmsis.h"
|
||||
|
||||
|
||||
#include "mico_rtos.h"
|
||||
#include "RingBufferUtils.h"
|
||||
|
||||
//#include "lowlevel_drivers.h"
|
||||
//#include "boot_flags.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/******************************************************
|
||||
* Macros
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Constants
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Enumerations
|
||||
******************************************************/
|
||||
|
||||
/******************************************************
|
||||
* Type Definitions
|
||||
******************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* UART flow control for driver
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
FLOW_CONTROL_DISABLED_DRV,
|
||||
FLOW_CONTROL_CTS_DRV,
|
||||
FLOW_CONTROL_RTS_DRV,
|
||||
FLOW_CONTROL_CTS_RTS_DRV
|
||||
} platform_uart_driver_flow_control_t;
|
||||
|
||||
/******************************************************
|
||||
* Structures
|
||||
******************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unimplemented;
|
||||
} 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;
|
||||
mico_bool_t initialized;
|
||||
} platform_spi_driver_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unimplemented;
|
||||
} platform_spi_slave_driver_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unimplemented;
|
||||
} platform_i2c_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mico_mutex_t i2c_mutex;
|
||||
} platform_i2c_driver_t;
|
||||
|
||||
typedef void (* wakeup_irq_handler_t)(void *arg);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t port_id;
|
||||
} platform_uart_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t id;
|
||||
ring_buffer_t* rx_ring_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;
|
||||
platform_uart_driver_flow_control_t flow_control;
|
||||
} platform_uart_driver_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t flash_type;
|
||||
uint32_t flash_start_addr;
|
||||
uint32_t flash_length;
|
||||
} 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
|
||||
******************************************************/
|
||||
//int get_passive_firmware(void);
|
||||
//int part_write_layout(void);
|
||||
|
||||
|
||||
|
||||
//OSStatus platform_gpio_irq_manager_init ( void );
|
||||
//uint8_t platform_gpio_get_port_number ( platform_gpio_port_t* gpio_port );
|
||||
//OSStatus platform_gpio_enable_clock ( const platform_gpio_t* gpio );
|
||||
//OSStatus platform_gpio_set_alternate_function( platform_gpio_port_t* gpio_port, uint8_t pin_number, GPIOOType_TypeDef output_type, GPIOPuPd_TypeDef pull_up_down_type, uint8_t alternation_function );
|
||||
//
|
||||
//OSStatus platform_mcu_powersave_init ( void );
|
||||
//
|
||||
//OSStatus platform_rtc_init ( void );
|
||||
//OSStatus platform_rtc_enter_powersave ( void );
|
||||
//OSStatus platform_rtc_abort_powersave ( void );
|
||||
//OSStatus platform_rtc_exit_powersave ( uint32_t requested_sleep_time, uint32_t *cpu_sleep_time );
|
||||
//
|
||||
//uint8_t platform_uart_get_port_number ( platform_uart_port_t* uart );
|
||||
//void platform_uart_irq ( platform_uart_driver_t* driver );
|
||||
//void platform_uart_tx_dma_irq ( platform_uart_driver_t* driver );
|
||||
//void platform_uart_rx_dma_irq ( platform_uart_driver_t* driver );
|
||||
//
|
||||
//uint8_t platform_spi_get_port_number ( platform_spi_port_t* spi );
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user