mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-17 15:38:14 +08:00
修改了Web后台的部分界面,增加了HAmqtt中的总电量传感器,后台新增mqtt上报频率设置
This commit is contained in:
56
mico-os/platform/MCU/MX1290/moc/lwip_api_define.h
Normal file
56
mico-os/platform/MCU/MX1290/moc/lwip_api_define.h
Normal file
@@ -0,0 +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 );
|
||||
|
||||
/* 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
|
||||
325
mico-os/platform/MCU/MX1290/moc/moc_adapter.c
Normal file
325
mico-os/platform/MCU/MX1290/moc/moc_adapter.c
Normal file
@@ -0,0 +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 );
|
||||
}
|
||||
#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();
|
||||
}
|
||||
|
||||
|
||||
793
mico-os/platform/MCU/MX1290/moc/moc_api.c
Normal file
793
mico-os/platform/MCU/MX1290/moc/moc_api.c
Normal file
@@ -0,0 +1,793 @@
|
||||
#include "common.h"
|
||||
#include "moc_api.h"
|
||||
|
||||
extern const mico_api_t *lib_api_p;
|
||||
|
||||
/* WIFI MGR */
|
||||
OSStatus StartNetwork(network_InitTypeDef_st* inNetworkInitPara)
|
||||
{
|
||||
return lib_api_p->micoWlanStart(inNetworkInitPara);
|
||||
}
|
||||
OSStatus StartAdvNetwork(network_InitTypeDef_adv_st* inNetworkInitParaAdv)
|
||||
{
|
||||
return lib_api_p->micoWlanStartAdv(inNetworkInitParaAdv);
|
||||
}
|
||||
OSStatus getNetPara(IPStatusTypedef *outNetpara, WiFi_Interface inInterface)
|
||||
{
|
||||
return lib_api_p->micoWlanGetIPStatus(outNetpara, inInterface);
|
||||
}
|
||||
OSStatus CheckNetLink(LinkStatusTypeDef *outStatus)
|
||||
{
|
||||
return lib_api_p->micoWlanGetLinkStatus(outStatus);
|
||||
}
|
||||
void mxchipStartScan(void)
|
||||
{
|
||||
lib_api_p->micoWlanStartScan();
|
||||
}
|
||||
void mxchipStartAdvScan(void)
|
||||
{
|
||||
lib_api_p->micoWlanStartScanAdv();
|
||||
}
|
||||
OSStatus wifi_power_down(void)
|
||||
{
|
||||
return lib_api_p->micoWlanPowerOff();
|
||||
}
|
||||
OSStatus wifi_power_up(void)
|
||||
{
|
||||
return lib_api_p->micoWlanPowerOn();
|
||||
}
|
||||
OSStatus wlan_disconnect(void)
|
||||
{
|
||||
return lib_api_p->micoWlanSuspend();
|
||||
}
|
||||
OSStatus sta_disconnect(void)
|
||||
{
|
||||
return lib_api_p->micoWlanSuspendStation();
|
||||
}
|
||||
OSStatus uap_stop(void)
|
||||
{
|
||||
return lib_api_p->micoWlanSuspendSoftAP();
|
||||
}
|
||||
OSStatus OpenEasylink2_withdata(int inTimeout)
|
||||
{
|
||||
return lib_api_p->micoWlanStartEasyLink(inTimeout);
|
||||
}
|
||||
OSStatus OpenEasylink(int inTimeout)
|
||||
{
|
||||
return lib_api_p->micoWlanStartEasyLinkPlus(inTimeout);
|
||||
}
|
||||
OSStatus CloseEasylink2(void)
|
||||
{
|
||||
return lib_api_p->micoWlanStopEasyLink();
|
||||
}
|
||||
OSStatus CloseEasylink(void)
|
||||
{
|
||||
return lib_api_p->micoWlanStopEasyLinkPlus();
|
||||
}
|
||||
OSStatus OpenConfigmodeWPS(int inTimeout)
|
||||
{
|
||||
return lib_api_p->micoWlanStartWPS(inTimeout);
|
||||
}
|
||||
OSStatus CloseConfigmodeWPS(void)
|
||||
{
|
||||
return lib_api_p->micoWlanStopWPS();
|
||||
}
|
||||
OSStatus OpenAirkiss(int inTimeout)
|
||||
{
|
||||
return lib_api_p->micoWlanStartAirkiss(inTimeout);
|
||||
}
|
||||
OSStatus CloseAirkiss(void)
|
||||
{
|
||||
return lib_api_p->micoWlanStopAirkiss();
|
||||
}
|
||||
void ps_enable(void)
|
||||
{
|
||||
lib_api_p->micoWlanEnablePowerSave();
|
||||
}
|
||||
void ps_disable(void)
|
||||
{
|
||||
lib_api_p->micoWlanDisablePowerSave();
|
||||
}
|
||||
void wifimgr_debug_enable(bool enable)
|
||||
{
|
||||
lib_api_p->wifimgr_debug_enable(enable);
|
||||
}
|
||||
int mico_wlan_monitor_rx_type(int type)
|
||||
{
|
||||
return lib_api_p->mico_wlan_monitor_rx_type(type);
|
||||
}
|
||||
int mico_wlan_start_monitor(void)
|
||||
{
|
||||
return lib_api_p->mico_wlan_start_monitor();
|
||||
}
|
||||
int mico_wlan_stop_monitor(void)
|
||||
{
|
||||
return lib_api_p->mico_wlan_stop_monitor();
|
||||
}
|
||||
int mico_wlan_set_channel(uint8_t channel)
|
||||
{
|
||||
return lib_api_p->mico_wlan_set_channel((int)channel);
|
||||
}
|
||||
void mico_wlan_register_monitor_cb(monitor_cb_t fn)
|
||||
{
|
||||
lib_api_p->mico_wlan_register_monitor_cb(fn);
|
||||
}
|
||||
|
||||
int mxchip_active_scan(char*ssid, int is_adv)
|
||||
{
|
||||
return lib_api_p->mxchip_active_scan(ssid, is_adv);
|
||||
}
|
||||
|
||||
void wlan_set_channel(int channel)
|
||||
{
|
||||
lib_api_p->wlan_set_channel(channel);
|
||||
}
|
||||
|
||||
OSStatus mico_wlan_custom_ie_add(wlan_if_t wlan_if, uint8_t *custom_ie, uint32_t len)
|
||||
{
|
||||
return lib_api_p->wifi_manage_custom_ie_add(wlan_if, custom_ie, len);
|
||||
}
|
||||
|
||||
OSStatus mico_wlan_custom_ie_delete(wlan_if_t wlan_if, custom_ie_delete_op_t op, uint8_t *option_data, uint32_t len)
|
||||
{
|
||||
return lib_api_p->wifi_manage_custom_ie_delete(wlan_if);
|
||||
}
|
||||
|
||||
/* HAL: GPIO
|
||||
{
|
||||
return lib_api_p->;
|
||||
} FLASH
|
||||
{
|
||||
return lib_api_p->;
|
||||
} UART */
|
||||
mico_logic_partition_t* MicoFlashGetInfo( mico_partition_t inPartition )
|
||||
{
|
||||
return lib_api_p->MicoFlashGetInfo(inPartition);
|
||||
}
|
||||
OSStatus MicoFlashErase(mico_partition_t inPartition, uint32_t off_set, uint32_t size)
|
||||
{
|
||||
return lib_api_p->MicoFlashErase(inPartition, off_set, size);
|
||||
}
|
||||
OSStatus MicoFlashWrite( mico_partition_t inPartition, volatile uint32_t* off_set, uint8_t* inBuffer ,uint32_t inBufferLength)
|
||||
{
|
||||
lib_api_p->MicoFlashWrite(inPartition, off_set, inBuffer, inBufferLength);
|
||||
return 0;
|
||||
}
|
||||
OSStatus MicoFlashRead( mico_partition_t inPartition, volatile uint32_t* off_set, uint8_t* outBuffer, uint32_t inBufferLength)
|
||||
{
|
||||
return lib_api_p->MicoFlashRead(inPartition, off_set, outBuffer, inBufferLength);
|
||||
}
|
||||
OSStatus MicoFlashEnableSecurity( mico_partition_t partition, uint32_t off_set, uint32_t size )
|
||||
{
|
||||
return lib_api_p->MicoFlashEnableSecurity(partition, off_set, size );
|
||||
}
|
||||
|
||||
OSStatus MicoGpioInitialize( mico_gpio_t gpio, mico_gpio_config_t configuration )
|
||||
{
|
||||
return lib_api_p->MicoGpioInitialize(gpio, configuration );
|
||||
}
|
||||
OSStatus MicoGpioFinalize( mico_gpio_t gpio )
|
||||
{
|
||||
return lib_api_p->MicoGpioFinalize(gpio);
|
||||
}
|
||||
OSStatus MicoGpioOutputHigh( mico_gpio_t gpio )
|
||||
{
|
||||
return lib_api_p->MicoGpioOutputHigh(gpio);
|
||||
}
|
||||
OSStatus MicoGpioOutputLow( mico_gpio_t gpio )
|
||||
{
|
||||
return lib_api_p->MicoGpioOutputLow(gpio);
|
||||
}
|
||||
OSStatus MicoGpioOutputTrigger( mico_gpio_t gpio )
|
||||
{
|
||||
return lib_api_p->MicoGpioOutputTrigger(gpio);
|
||||
}
|
||||
bool MicoGpioInputGet( mico_gpio_t gpio )
|
||||
{
|
||||
return lib_api_p->MicoGpioInputGet(gpio);
|
||||
}
|
||||
OSStatus MicoGpioEnableIRQ( mico_gpio_t gpio, mico_gpio_irq_trigger_t trigger, mico_gpio_irq_handler_t handler, void* arg )
|
||||
{
|
||||
return lib_api_p->MicoGpioEnableIRQ(gpio, trigger, handler, arg );
|
||||
}
|
||||
OSStatus MicoGpioDisableIRQ( mico_gpio_t gpio )
|
||||
{
|
||||
return lib_api_p->MicoGpioDisableIRQ(gpio);
|
||||
}
|
||||
|
||||
OSStatus MicoUartInitialize( mico_uart_t uart, const mico_uart_config_t* config, ring_buffer_t* optional_rx_buffer )
|
||||
{
|
||||
return lib_api_p->MicoUartInitialize(uart, config, optional_rx_buffer );
|
||||
}
|
||||
OSStatus MicoUartFinalize( mico_uart_t uart )
|
||||
{
|
||||
return lib_api_p->MicoUartFinalize(uart);
|
||||
}
|
||||
OSStatus MicoUartSend( mico_uart_t uart, const void* data, uint32_t size )
|
||||
{
|
||||
OSStatus err;
|
||||
MicoMcuPowerSaveConfig(0);
|
||||
err = lib_api_p->MicoUartSend(uart, data, size );
|
||||
MicoMcuPowerSaveConfig(1);
|
||||
return err;
|
||||
}
|
||||
OSStatus MicoUartRecv( mico_uart_t uart, void* data, uint32_t size, uint32_t timeout )
|
||||
{
|
||||
return lib_api_p->MicoUartRecv(uart, data, size, timeout );
|
||||
}
|
||||
uint32_t MicoUartGetLengthInBuffer( mico_uart_t uart )
|
||||
{
|
||||
return lib_api_p->MicoUartGetLengthInBuffer(uart);
|
||||
}
|
||||
|
||||
void wifistate_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->wifistate_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
|
||||
void wifidebug_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->wifidebug_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
void wifiscan_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->wifiscan_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
|
||||
void ifconfig_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->ifconfig_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
void arp_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->arp_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
void ping_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->ping_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
void dns_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->dns_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
void task_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->task_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
void socket_show_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->socket_show_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
void memory_show_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->memory_show_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
void memory_dump_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->memory_dump_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
void memory_set_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->memory_set_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
void memp_dump_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->memp_dump_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
void driver_state_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->driver_state_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
WEAK void iperf_Command(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv)
|
||||
{
|
||||
lib_api_p->iperf_Command(pcWriteBuffer, xWriteBufferLen, argc, argv);
|
||||
}
|
||||
|
||||
int wlan_driver_version( char* outVersion, uint8_t inLength )
|
||||
{
|
||||
return lib_api_p->wlan_driver_version(outVersion, inLength);
|
||||
}
|
||||
|
||||
void mico_wlan_get_mac_address( uint8_t *mac )
|
||||
{
|
||||
lib_api_p->wlan_get_mac_address(mac);
|
||||
}
|
||||
|
||||
void mico_wlan_get_mac_address_by_interface( wlan_if_t wlan_if, uint8_t *mac )
|
||||
{
|
||||
lib_api_p->wlan_get_mac_address_by_interface(wlan_if, mac);
|
||||
}
|
||||
|
||||
void InitMd5(md5_context*md5)
|
||||
{
|
||||
lib_api_p->InitMd5(md5);
|
||||
}
|
||||
void Md5Update(md5_context* md5, unsigned char *input, int ilen)
|
||||
{
|
||||
lib_api_p->Md5Update(md5, input, ilen);
|
||||
}
|
||||
void Md5Final(md5_context* md5, uint8_t* hash)
|
||||
{
|
||||
lib_api_p->Md5Final(md5, hash);
|
||||
}
|
||||
int Md5Hash(const uint8_t* data, uint32_t len, uint8_t* hash)
|
||||
{
|
||||
return lib_api_p->Md5Hash(data, len, hash);
|
||||
}
|
||||
void AesEncryptDirect(Aes* aes, uint8_t* out, const uint8_t* in)
|
||||
{
|
||||
lib_api_p->AesEncryptDirect(aes, out, in);
|
||||
}
|
||||
void AesDecryptDirect(Aes* aes, uint8_t* out, const uint8_t* in)
|
||||
{
|
||||
lib_api_p->AesDecryptDirect(aes, out, in);
|
||||
}
|
||||
//int AesSetKeyDirect(Aes* aes, const byte* key, word32 ilen,const byte* out, int dir);
|
||||
int AesSetKeyDirect(Aes* aes, const unsigned char* key, unsigned int len, const unsigned char* iv, int dir)
|
||||
{
|
||||
return lib_api_p->AesSetKeyDirect(aes, key, len, iv, dir);
|
||||
}
|
||||
int aes_encrypt(int sz, const char * key, const char * in, char * out)
|
||||
{
|
||||
return lib_api_p->aes_encrypt(sz, key, in, out);
|
||||
}
|
||||
int aes_decrypt(int sz, const char * key, const char * in, char * out)
|
||||
{
|
||||
return lib_api_p->aes_decrypt(sz, key, in, out);
|
||||
}
|
||||
int AesSetKey(Aes* aes, const uint8_t* key, unsigned int len,
|
||||
const uint8_t* iv, int dir)
|
||||
{
|
||||
return lib_api_p->AesSetKey(aes, key, len, iv, dir);
|
||||
}
|
||||
int AesSetIV(Aes* aes, const uint8_t* iv)
|
||||
{
|
||||
return lib_api_p->AesSetIV(aes, iv);
|
||||
}
|
||||
int AesCbcEncrypt(Aes* aes, uint8_t* out,
|
||||
const uint8_t* in, unsigned int sz)
|
||||
{
|
||||
return lib_api_p->AesCbcEncrypt(aes, out, in, sz);
|
||||
}
|
||||
int AesCbcDecrypt(Aes* aes, uint8_t* out,
|
||||
const uint8_t* in, unsigned int sz){
|
||||
return lib_api_p->AesCbcDecrypt(aes, out, in, sz);
|
||||
}
|
||||
|
||||
OSStatus mxchipInit(void)
|
||||
{
|
||||
lib_api_p->mxchipInit();
|
||||
return kNoErr;
|
||||
}
|
||||
|
||||
micoMemInfo_t* mico_memory_info(void)
|
||||
{
|
||||
return lib_api_p->mico_memory_info();
|
||||
}
|
||||
char* system_lib_version(void)
|
||||
{
|
||||
return lib_api_p->library_version;
|
||||
}
|
||||
|
||||
void MicoSystemReboot(void)
|
||||
{
|
||||
lib_api_p->MicoSystemReboot();
|
||||
}
|
||||
|
||||
char *mico_get_bootloader_ver(void)
|
||||
{
|
||||
return "bootloader";
|
||||
}
|
||||
|
||||
void MicoWakeupSource( uint8_t wakeup_source )
|
||||
{
|
||||
lib_api_p->pm_wakeup_source(wakeup_source);
|
||||
}
|
||||
|
||||
void MicoSystemStandBy( uint32_t secondsToWakeup )
|
||||
{
|
||||
lib_api_p->wifi_off_mcu_standby(secondsToWakeup);
|
||||
}
|
||||
|
||||
char *get_ali_key(void)
|
||||
{
|
||||
return lib_api_p->get_ali_key();
|
||||
}
|
||||
|
||||
char *get_ali_secret(void)
|
||||
{
|
||||
return lib_api_p->get_ali_secret();
|
||||
}
|
||||
|
||||
void MicoRtcInitialize(void)
|
||||
{
|
||||
lib_api_p->MicoRtcInitialize();
|
||||
}
|
||||
|
||||
OSStatus MicoRtcGetTime(mico_rtc_time_t* time)
|
||||
{
|
||||
int ret = lib_api_p->MicoRtcGetTime(time);
|
||||
return ret;
|
||||
}
|
||||
|
||||
OSStatus MicoRtcSetTime(mico_rtc_time_t* time)
|
||||
{
|
||||
return lib_api_p->MicoRtcSetTime(time);
|
||||
}
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
struct tm *localtime(const time_t * time)
|
||||
{
|
||||
return lib_api_p->localtime(time);
|
||||
}
|
||||
#endif
|
||||
|
||||
char *asctime(const struct tm *tm)
|
||||
{
|
||||
return lib_api_p->asctime(tm);
|
||||
}
|
||||
|
||||
int wifi_set_country(int country)
|
||||
{
|
||||
return lib_api_p->wifi_set_country(country);
|
||||
}
|
||||
|
||||
int switch_active_firmware(void)
|
||||
{
|
||||
return lib_api_p->switch_active_firmrware();
|
||||
}
|
||||
|
||||
int get_last_reset_reason(void)
|
||||
{
|
||||
return lib_api_p->last_reset_reason();
|
||||
}
|
||||
|
||||
void system_config_set(mico_system_config_t *cfg)
|
||||
{
|
||||
lib_api_p->system_config_set(cfg);
|
||||
}
|
||||
|
||||
mico_system_config_t *system_config_get(void)
|
||||
{
|
||||
return lib_api_p->system_config_get();
|
||||
}
|
||||
|
||||
int aon_write( uint32_t offset, uint8_t* in ,uint32_t len)
|
||||
{
|
||||
return lib_api_p->aon_write(offset, in, len);
|
||||
}
|
||||
|
||||
int aon_read( uint32_t offset, uint8_t* out, uint32_t len)
|
||||
{
|
||||
return lib_api_p->aon_read(offset, out, len);
|
||||
}
|
||||
|
||||
|
||||
int lwip_ioctl(int s, long cmd, void *argp)
|
||||
{
|
||||
return lib_api_p->lwip_apis->lwip_ioctl(s, cmd, argp);
|
||||
}
|
||||
int lwip_fcntl(int s, int cmd, int val)
|
||||
{
|
||||
return lib_api_p->lwip_apis->lwip_fcntl(s, cmd, val);
|
||||
}
|
||||
|
||||
void lwip_freeaddrinfo(struct addrinfo *ai)
|
||||
{
|
||||
lib_api_p->lwip_apis->lwip_freeaddrinfo(ai);
|
||||
}
|
||||
|
||||
int lwip_getaddrinfo(const char *nodename,
|
||||
const char *servname,
|
||||
const struct addrinfo *hints,
|
||||
struct addrinfo **res)
|
||||
{
|
||||
return lib_api_p->lwip_apis->lwip_getaddrinfo(nodename,
|
||||
servname, hints, res);
|
||||
}
|
||||
|
||||
char * ipaddr_ntoa(const ip_addr_t *addr)
|
||||
{
|
||||
return lib_api_p->lwip_apis->ipaddr_ntoa(addr);
|
||||
}
|
||||
uint32_t ipaddr_addr(const char *cp)
|
||||
{
|
||||
return lib_api_p->lwip_apis->ipaddr_addr(cp);
|
||||
}
|
||||
|
||||
uint16_t
|
||||
lwip_htons(uint16_t n)
|
||||
{
|
||||
return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an uint16_t from network- to host byte order.
|
||||
*
|
||||
* @param n uint16_t in network byte order
|
||||
* @return n in host byte order
|
||||
*/
|
||||
uint16_t
|
||||
lwip_ntohs(uint16_t n)
|
||||
{
|
||||
return lwip_htons(n);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an uint32_t from host- to network byte order.
|
||||
*
|
||||
* @param n uint32_t in host byte order
|
||||
* @return n in network byte order
|
||||
*/
|
||||
uint32_t
|
||||
lwip_htonl(uint32_t n)
|
||||
{
|
||||
return ((n & 0xff) << 24) |
|
||||
((n & 0xff00) << 8) |
|
||||
((n & 0xff0000UL) >> 8) |
|
||||
((n & 0xff000000UL) >> 24);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an uint32_t from network- to host byte order.
|
||||
*
|
||||
* @param n uint32_t in network byte order
|
||||
* @return n in host byte order
|
||||
*/
|
||||
uint32_t
|
||||
lwip_ntohl(uint32_t n)
|
||||
{
|
||||
return lwip_htonl(n);
|
||||
}
|
||||
|
||||
OSStatus MicoPwmInitialize(mico_pwm_t pwm, uint32_t freequency, float duty_cycle)
|
||||
{
|
||||
return lib_api_p->pwm_apis->pwm_init(pwm, freequency, duty_cycle);
|
||||
}
|
||||
|
||||
OSStatus MicoPwmStart(mico_pwm_t pwm)
|
||||
{
|
||||
return lib_api_p->pwm_apis->pwm_start(pwm);
|
||||
}
|
||||
|
||||
OSStatus MicoPwmStop(mico_pwm_t pwm)
|
||||
{
|
||||
return lib_api_p->pwm_apis->pwm_stop(pwm);
|
||||
}
|
||||
|
||||
|
||||
OSStatus MicoGtimerInitialize(mico_gtimer_t gtimer)
|
||||
{
|
||||
return lib_api_p->gtimer_apis->MicoGtimerInitialize(gtimer);
|
||||
}
|
||||
|
||||
OSStatus MicoGtimerStart(mico_gtimer_t gtimer, mico_gtimer_mode_t mode, uint32_t time, mico_gtimer_irq_callback_t function, void *arg)
|
||||
{
|
||||
return lib_api_p->gtimer_apis->MicoGtimerStart(gtimer, mode, time, function, arg);
|
||||
}
|
||||
|
||||
OSStatus MicoGtimerStop(mico_gtimer_t gtimer)
|
||||
{
|
||||
return lib_api_p->gtimer_apis->MicoGtimerStop(gtimer);
|
||||
}
|
||||
|
||||
OSStatus MicoWdgInitialize( uint32_t timeout )
|
||||
{
|
||||
return lib_api_p->wdg_apis->wdg_init(timeout);
|
||||
}
|
||||
|
||||
void MicoWdgReload( void )
|
||||
{
|
||||
lib_api_p->wdg_apis->wdg_reload();
|
||||
}
|
||||
|
||||
OSStatus MicoWdgFinalize( void )
|
||||
{
|
||||
return lib_api_p->wdg_apis->wdg_stop();
|
||||
}
|
||||
|
||||
int Cyassl_get_fd(const void *ssl)
|
||||
{
|
||||
return lib_api_p->ssl_get_fd(ssl);
|
||||
}
|
||||
|
||||
OSStatus MicoAdcInitialize( mico_adc_t adc, uint32_t sampling_cycle )
|
||||
{
|
||||
return lib_api_p->adc_apis->MicoAdcInitialize(adc, sampling_cycle);
|
||||
}
|
||||
|
||||
OSStatus MicoAdcFinalize( mico_adc_t adc )
|
||||
{
|
||||
return lib_api_p->adc_apis->MicoAdcFinalize(adc);
|
||||
}
|
||||
|
||||
OSStatus MicoAdcTakeSample( mico_adc_t adc, uint16_t* output )
|
||||
{
|
||||
return lib_api_p->adc_apis->MicoAdcTakeSample(adc, output);
|
||||
}
|
||||
|
||||
OSStatus MicoAdcTakeSampleStreram( mico_adc_t adc, void* buffer, uint16_t buffer_length )
|
||||
{
|
||||
return lib_api_p->adc_apis->MicoAdcTakeSampleStreram(adc, buffer, buffer_length);
|
||||
}
|
||||
|
||||
OSStatus MicoI2cInitialize( mico_i2c_device_t* device )
|
||||
{
|
||||
OSStatus result;
|
||||
|
||||
result = lib_api_p->i2c_apis->i2c_init(device);
|
||||
return result;
|
||||
}
|
||||
|
||||
OSStatus MicoI2cFinalize( mico_i2c_device_t* device )
|
||||
{
|
||||
return lib_api_p->i2c_apis->i2c_deinit(device);
|
||||
}
|
||||
|
||||
bool MicoI2cProbeDevice( mico_i2c_device_t* device, int retries )
|
||||
{
|
||||
bool ret;
|
||||
|
||||
ret = lib_api_p->i2c_apis->i2c_probe_device(device, retries);
|
||||
return ret;
|
||||
}
|
||||
|
||||
OSStatus MicoI2cBuildTxMessage( mico_i2c_message_t* message, const void* tx_buffer, uint16_t tx_buffer_length, uint16_t retries )
|
||||
{
|
||||
return lib_api_p->i2c_apis->i2c_build_tx_msg(message, tx_buffer, tx_buffer_length, retries );
|
||||
}
|
||||
|
||||
OSStatus MicoI2cBuildRxMessage( mico_i2c_message_t* message, void* rx_buffer, uint16_t rx_buffer_length, uint16_t retries )
|
||||
{
|
||||
return lib_api_p->i2c_apis->i2c_build_rx_msg(message, rx_buffer, rx_buffer_length, retries );
|
||||
}
|
||||
|
||||
OSStatus MicoI2cBuildCombinedMessage( mico_i2c_message_t* message, const void* tx_buffer, void* rx_buffer, uint16_t tx_buffer_length, uint16_t rx_buffer_length, uint16_t retries )
|
||||
{
|
||||
return lib_api_p->i2c_apis->i2c_build_combined_msg(message, tx_buffer, rx_buffer,
|
||||
tx_buffer_length, rx_buffer_length, retries );
|
||||
}
|
||||
|
||||
OSStatus MicoI2cTransfer( mico_i2c_device_t* device, mico_i2c_message_t* messages, uint16_t number_of_messages )
|
||||
{
|
||||
OSStatus err = kNoErr;
|
||||
|
||||
err = lib_api_p->i2c_apis->i2c_transfer(device, messages, number_of_messages);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
OSStatus MicoSpiInitialize( const mico_spi_device_t* spi )
|
||||
{
|
||||
lib_api_p->spi_apis->spi_init(spi);
|
||||
return kNoErr;
|
||||
}
|
||||
|
||||
OSStatus MicoSpiFinalize( const mico_spi_device_t* spi )
|
||||
{
|
||||
return lib_api_p->spi_apis->spi_finalize(spi);
|
||||
}
|
||||
|
||||
OSStatus MicoSpiTransfer( const mico_spi_device_t* spi, const mico_spi_message_segment_t* segments, uint16_t number_of_segments )
|
||||
{
|
||||
return lib_api_p->spi_apis->spi_transfer(spi, segments, number_of_segments );
|
||||
}
|
||||
|
||||
|
||||
OSStatus MicoRandomNumberRead( void *inBuffer, int inByteCount )
|
||||
{
|
||||
lib_api_p->get_random_sequence(inBuffer, inByteCount);
|
||||
return kNoErr;
|
||||
}
|
||||
|
||||
uint32_t RNG_GetRandomNumber(void)
|
||||
{
|
||||
uint32_t d;
|
||||
MicoRandomNumberRead((unsigned char*)&d, 4);
|
||||
return d;
|
||||
}
|
||||
|
||||
int wlan_inject_frame(const uint8_t *buff, size_t len)
|
||||
{
|
||||
return lib_api_p->wlan_inject_frame(buff, len);
|
||||
}
|
||||
|
||||
OSStatus mico_wlan_send_mgnt(uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
// I don't know the return value;
|
||||
lib_api_p->wlan_inject_frame(buffer, length);
|
||||
return kNoErr;
|
||||
}
|
||||
|
||||
void MicoMcuPowerSaveConfig(int enable)
|
||||
{
|
||||
static int ps_cnt = 1;
|
||||
|
||||
if(enable == 0)
|
||||
{
|
||||
if(ps_cnt++ == 0)
|
||||
{
|
||||
lib_api_p->MicoMcuPowerSaveConfig(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(--ps_cnt== 0)
|
||||
{
|
||||
lib_api_p->MicoMcuPowerSaveConfig(1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This API can be used to start/stop the management frame forwards
|
||||
* to host through datapath.
|
||||
*
|
||||
* \param[in] bss_type The interface from which management frame needs to be
|
||||
* collected.
|
||||
* \param[in] mgmt_subtype_mask Management Subtype Mask
|
||||
* If Bit X is set in mask, it means that IEEE Management Frame
|
||||
* SubTyoe X is to be filtered and passed through to host.
|
||||
* Bit Description
|
||||
* [31:14] Reserved
|
||||
* [13] Action frame
|
||||
* [12:9] Reserved
|
||||
* [8] Beacon
|
||||
* [7:6] Reserved
|
||||
* [5] Probe response
|
||||
* [4] Probe request
|
||||
* [3] Reassociation response
|
||||
* [2] Reassociation request
|
||||
* [1] Association response
|
||||
* [0] Association request
|
||||
* Support multiple bits set.
|
||||
* 0 = stop forward frame
|
||||
* 1 = start forward frame
|
||||
*
|
||||
*\param[in] rx_mgmt_callback The receive callback where the received management
|
||||
* frames are passed.
|
||||
|
||||
* \return WM_SUCCESS if operation is successful.
|
||||
* \return -WM_FAIL if command fails.
|
||||
*
|
||||
* \note Pass Management Subtype Mask all zero to disable all the management
|
||||
* frame forward to host.
|
||||
*/
|
||||
int wlan_rx_mgmt_indication(const enum wlan_bss_type bss_type,
|
||||
const uint32_t mgmt_subtype_mask,
|
||||
void (*rx_mgmt_callback)(const enum wlan_bss_type
|
||||
bss_type, const uint8_t *frame,
|
||||
const uint16_t len))
|
||||
{
|
||||
return lib_api_p->wlan_rx_mgmt_indication(
|
||||
bss_type, mgmt_subtype_mask, rx_mgmt_callback);
|
||||
}
|
||||
|
||||
|
||||
int wlan_remain_on_channel(const bool status, const uint8_t channel,
|
||||
const uint32_t ms)
|
||||
{
|
||||
return lib_api_p->wlan_remain_on_channel(status, channel, ms);
|
||||
}
|
||||
|
||||
int wifi_bridge_mode_enable(bool hidden_ssid)
|
||||
{
|
||||
return lib_api_p->wifi_bridge_mode_enable(hidden_ssid);
|
||||
}
|
||||
|
||||
int wifi_bridge_mode_disable(void)
|
||||
{
|
||||
return lib_api_p->wifi_bridge_mode_disable();
|
||||
}
|
||||
|
||||
int send_easylink_minus(uint32_t ip, char *ssid, char *key)
|
||||
{
|
||||
return lib_api_p->send_easylink_minus(ip, ssid, key);
|
||||
}
|
||||
|
||||
OSStatus mico_wlan_get_channel( uint8_t *channel )
|
||||
{
|
||||
*channel = lib_api_p->mico_wlan_get_channel();
|
||||
return kNoErr;
|
||||
}
|
||||
697
mico-os/platform/MCU/MX1290/moc/moc_api.h
Normal file
697
mico-os/platform/MCU/MX1290/moc/moc_api.h
Normal file
@@ -0,0 +1,697 @@
|
||||
#ifndef _MICO_API_H_
|
||||
#define _MICO_API_H_
|
||||
|
||||
#include "lwip_api_define.h"
|
||||
#include "mico.h"
|
||||
|
||||
#define INTERFACE_VERSION 3
|
||||
|
||||
typedef void (*ssl_Logging_cb)( const int logLevel,
|
||||
const char * const logMessage );
|
||||
|
||||
#ifndef BIT
|
||||
#define BIT(__n) (1<<(__n))
|
||||
#endif
|
||||
|
||||
#define DSLEEP_WAKEUP_BY_TIMER BIT(0)
|
||||
#define DSLEEP_WAKEUP_BY_GPIO BIT(2) // GPIO Port(PA_18, PA_5, PA_22, PA_23)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
/** US FCC */
|
||||
COUNTRY_US = 1,
|
||||
/** IC Canada */
|
||||
COUNTRY_CA,
|
||||
/** Singapore */
|
||||
COUNTRY_SG,
|
||||
/** ETSI */
|
||||
COUNTRY_EU,
|
||||
/** Australia */
|
||||
COUNTRY_AU,
|
||||
/** Republic Of Korea */
|
||||
COUNTRY_KR,
|
||||
/** France */
|
||||
COUNTRY_FR,
|
||||
/** Japan */
|
||||
COUNTRY_JP,
|
||||
/** China */
|
||||
COUNTRY_CN,
|
||||
} country_code_t;
|
||||
enum wlan_bss_type
|
||||
{
|
||||
WLAN_BSS_TYPE_STA = 0,
|
||||
WLAN_BSS_TYPE_UAP = 1,
|
||||
WLAN_BSS_TYPE_WIFIDIRECT = 2,
|
||||
WLAN_BSS_TYPE_ANY = 0xff,
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
ASSOC_REQ_FRAME = 0x00,
|
||||
ASSOC_RESP_FRAME = 0x10,
|
||||
REASSOC_REQ_FRAME = 0x20,
|
||||
REASSOC_RESP_FRAME = 0x30,
|
||||
PROBE_REQ_FRAME = 0x40,
|
||||
PROBE_RESP_FRAME = 0x50,
|
||||
BEACON_FRAME = 0x80,
|
||||
DISASSOC_FRAME = 0xA0,
|
||||
AUTH_FRAME = 0xB0,
|
||||
DEAUTH_FRAME = 0xC0,
|
||||
ACTION_FRAME = 0xD0,
|
||||
DATA_FRAME = 0x08,
|
||||
QOS_DATA_FRAME = 0x88,
|
||||
} wifi_frame_type_t;
|
||||
|
||||
/** 802_11_header packet */
|
||||
typedef struct _wifi_mgmt_frame_t
|
||||
{
|
||||
/** Packet Length */
|
||||
uint16_t frm_len;
|
||||
/** Frame Type */
|
||||
wifi_frame_type_t frame_type;
|
||||
/** Frame Control flags */
|
||||
uint8_t frame_ctrl_flags;
|
||||
/** Duration ID */
|
||||
uint16_t duration_id;
|
||||
/** Address1 */
|
||||
uint8_t addr1[6];
|
||||
/** Address2 */
|
||||
uint8_t addr2[6];
|
||||
/** Address3 */
|
||||
uint8_t addr3[6];
|
||||
/** Sequence Control */
|
||||
uint16_t seq_ctl;
|
||||
/** Address4 */
|
||||
uint8_t addr4[6];
|
||||
/** Frame payload */
|
||||
uint8_t payload[0];
|
||||
} wlan_mgmt_frame_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
OSStatus (*pwm_init)( mico_pwm_t pwm, uint32_t frequency, float duty_cycle );
|
||||
OSStatus (*pwm_start)( mico_pwm_t pwm );
|
||||
OSStatus (*pwm_stop)( mico_pwm_t pwm );
|
||||
} pwm_api_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
OSStatus (*wdg_init)( uint32_t timeout );
|
||||
void (*wdg_reload)( void );
|
||||
OSStatus (*wdg_stop)( void );
|
||||
} wdg_api_t;
|
||||
|
||||
#define LAST_RST_CAUSE_VBAT (1<<0)
|
||||
#define LAST_RST_CAUSE_AV12 (1<<1)
|
||||
#define LAST_RST_CAUSE_AV18 (1<<2)
|
||||
#define LAST_RST_CAUSE_SOFTRST (1<<3)
|
||||
#define LAST_RST_CAUSE_LOCKUP (1<<4)
|
||||
#define LAST_RST_CAUSE_WDT (1<<5)
|
||||
|
||||
#define USER_APP_ADDR 0x1f064000 /* 400KB offset */
|
||||
#define USER_MAGIC_NUM 0xC89346
|
||||
|
||||
#define time_t unsigned long
|
||||
/** Power States of MCU */
|
||||
typedef enum
|
||||
{
|
||||
|
||||
/** (Active Mode): This is the full power state of MCU.
|
||||
* Instruction execution takes place only in PM0.
|
||||
*/
|
||||
PM0,
|
||||
/** (Idle Mode): In this mode Cortex M3 core function
|
||||
* clocks are stopped until the occurrence of any interrupt.
|
||||
* This consumes lower power than PM0. */
|
||||
PM1,
|
||||
|
||||
/** (Standby Mode):In this mode, the Cortex M3,
|
||||
* most of the peripherals & SRAM arrays are in
|
||||
* low-power mode.The PMU and RTC are operational.
|
||||
* A wakeup can happen by timeout (RTC based) or by asserting the
|
||||
* WAKEUP 0/1 lines.This consumes much lower power than PM1.
|
||||
*/
|
||||
PM2,
|
||||
|
||||
/**(Sleep Mode): This mode further aggressively conserves power.
|
||||
* Only 192 KB (160 KB in SRAM0 and 32 KB in SRAM1)
|
||||
* out of 512 KB of SRAM is alive. All peripherals
|
||||
* are turned off and register config is lost.
|
||||
* Application should restore the peripheral config
|
||||
* after exit form PM3. This consumes lower power
|
||||
* than in PM2. A wakeup can happen by timeout (RTC based)
|
||||
* or by asserting the WAKEUP 0/1 lines.
|
||||
*/
|
||||
PM3,
|
||||
|
||||
/** (Shutoff Mode): This simulates a shutdown condition.
|
||||
* A wakeup can happen by timeout (RTC based) or by
|
||||
* asserting the WAKEUP 0/1 lines.
|
||||
* This is the lowest power state of MCU.
|
||||
* On wakeup execution begins from bootrom as
|
||||
* if a fresh bootup has occurred.
|
||||
*/
|
||||
PM4
|
||||
} power_state_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
OSStatus (*MicoAdcInitialize)( mico_adc_t adc, uint32_t sampling_cycle );
|
||||
OSStatus (*MicoAdcTakeSample)( mico_adc_t adc, uint16_t* output );
|
||||
OSStatus (*MicoAdcTakeSampleStreram)( mico_adc_t adc, void* buffer, uint16_t buffer_length );
|
||||
OSStatus (*MicoAdcFinalize)( mico_adc_t adc );
|
||||
} adc_api_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
OSStatus (*i2c_init)( mico_i2c_device_t* device );
|
||||
OSStatus (*i2c_deinit)( mico_i2c_device_t* device );
|
||||
bool (*i2c_probe_device)( mico_i2c_device_t* device, int retries );
|
||||
OSStatus (*i2c_build_tx_msg)( mico_i2c_message_t* message, const void* tx_buffer, uint16_t tx_buffer_length,
|
||||
uint16_t retries );
|
||||
OSStatus (*i2c_build_rx_msg)( mico_i2c_message_t* message, void* rx_buffer, uint16_t rx_buffer_length,
|
||||
uint16_t retries );
|
||||
OSStatus (*i2c_build_combined_msg)( mico_i2c_message_t* message, const void* tx_buffer, void* rx_buffer,
|
||||
uint16_t tx_buffer_length, uint16_t rx_buffer_length, uint16_t retries );
|
||||
OSStatus (*i2c_transfer)( mico_i2c_device_t* device, mico_i2c_message_t* messages, uint16_t number_of_messages );
|
||||
} i2c_api_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
OSStatus (*spi_init)( const mico_spi_device_t* spi );
|
||||
OSStatus (*spi_transfer)( const mico_spi_device_t* spi, const mico_spi_message_segment_t* segments,
|
||||
uint16_t number_of_segments );
|
||||
OSStatus (*spi_finalize)( const mico_spi_device_t* spi );
|
||||
} spi_api_t;
|
||||
|
||||
typedef struct {
|
||||
OSStatus (*MicoGtimerInitialize)(mico_gtimer_t gtimer);
|
||||
OSStatus (*MicoGtimerStart)(mico_gtimer_t timer, mico_gtimer_mode_t mode, uint32_t time, mico_gtimer_irq_callback_t function, void *arg);
|
||||
OSStatus (*MicoGtimerStop)(mico_gtimer_t timer);
|
||||
} gtimer_api_t;
|
||||
|
||||
/* API type define */
|
||||
typedef struct mico_api_struct
|
||||
{
|
||||
char *library_version;
|
||||
|
||||
/* OS Layer*/
|
||||
mico_system_config_t* (*system_config_get)( void );
|
||||
void (*system_config_set)( mico_system_config_t *cfg );
|
||||
void (*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, void* 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 );
|
||||
OSStatus (*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_t handle );
|
||||
int (*mico_delete_event_fd)( int fd );
|
||||
int (*SetTimer)( unsigned long ms, void (*psysTimerHandler)( void ) );
|
||||
int (*SetTimer_uniq)( unsigned long ms, void (*psysTimerHandler)( void ) );
|
||||
int (*UnSetTimer)( void (*psysTimerHandler)( void ) );
|
||||
|
||||
/* memory management*/
|
||||
micoMemInfo_t* (*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)( int a, int b ); // calloc
|
||||
void (*heap_insert)( uint8_t *pv, int len );
|
||||
|
||||
/* Socket */
|
||||
int (*socket)( int domain, int type, int protocol );
|
||||
int (*setsockopt)( int sockfd, int level, int optname, const void *optval, socklen_t optlen );
|
||||
int (*getsockopt)( int sockfd, int level, int optname, const void *optval, socklen_t *optlen );
|
||||
int (*bind)( int sockfd, const struct sockaddr *addr, socklen_t addrlen );
|
||||
int (*connect)( int sockfd, const struct sockaddr *addr, socklen_t addrlen );
|
||||
int (*listen)( int sockfd, int backlog );
|
||||
int (*accept)( int sockfd, struct sockaddr *addr, socklen_t *addrlen );
|
||||
int (*select)( int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout );
|
||||
ssize_t (*send)( int sockfd, const void *buf, size_t len, int flags );
|
||||
int (*write)( int sockfd, void *buf, size_t len );
|
||||
ssize_t (*sendto)( int sockfd, const void *buf, size_t len, int flags,
|
||||
const struct sockaddr *dest_addr,
|
||||
socklen_t addrlen );
|
||||
ssize_t (*recv)( int sockfd, void *buf, size_t len, int flags );
|
||||
int (*read)( int sockfd, void *buf, size_t len );
|
||||
ssize_t (*recvfrom)( int sockfd, void *buf, size_t len, int flags,
|
||||
struct sockaddr *src_addr,
|
||||
socklen_t *addrlen );
|
||||
int (*close)( int fd );
|
||||
uint32_t (*inet_addr)( char *s );
|
||||
char* (*inet_ntoa)( char *s, uint32_t x );
|
||||
int (*gethostbyname)( const char * name, uint8_t * addr, uint8_t addrLen );
|
||||
void (*set_tcp_keepalive)( int inMaxErrNum, int inSeconds );
|
||||
void (*get_tcp_keepalive)( int *outMaxErrNum, int *outSeconds );
|
||||
|
||||
/* SSL */
|
||||
void (*ssl_set_cert)( const char *_cert_pem, const char *private_key_pem );
|
||||
void* (*ssl_connect)( int fd, int calen, char*ca, int *ssl_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 );
|
||||
|
||||
/*crypto*/
|
||||
void (*InitMd5)( md5_context*md5 );
|
||||
void (*Md5Update)( md5_context* md5, unsigned char *input, int ilen );
|
||||
void (*Md5Final)( md5_context* 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 );
|
||||
|
||||
/* 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 );
|
||||
OSStatus (*micoWlanStartScan)( void );
|
||||
OSStatus (*micoWlanStartScanAdv)( void );
|
||||
OSStatus (*micoWlanPowerOff)( void );
|
||||
OSStatus (*micoWlanPowerOn)( void );
|
||||
OSStatus (*micoWlanSuspend)( void );
|
||||
OSStatus (*micoWlanSuspendStation)( void );
|
||||
OSStatus (*micoWlanSuspendSoftAP)( void );
|
||||
OSStatus (*micoWlanStartEasyLink)( int inTimeout );
|
||||
OSStatus (*micoWlanStartEasyLinkPlus)( int inTimeout );
|
||||
OSStatus (*micoWlanStopEasyLink)( void );
|
||||
OSStatus (*micoWlanStopEasyLinkPlus)( void );
|
||||
OSStatus (*micoWlanStartWPS)( int inTimeout );
|
||||
OSStatus (*micoWlanStopWPS)( void );
|
||||
OSStatus (*micoWlanStartAirkiss)( int inTimeout );
|
||||
OSStatus (*micoWlanStopAirkiss)( 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 );
|
||||
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);
|
||||
|
||||
/* 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 );
|
||||
|
||||
/* HAL: GPIO; FLASH; UART */
|
||||
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 );
|
||||
|
||||
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 );
|
||||
|
||||
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 );
|
||||
|
||||
/* 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)( int seconds );
|
||||
void (*MicoMcuPowerSaveConfig)( int enable );
|
||||
|
||||
/* uitls */
|
||||
int (*debug_putchar)( char *ch, int len );
|
||||
void (*MicoSystemReboot)( void );
|
||||
|
||||
/* ALI APIs */
|
||||
char* (*get_ali_key)( void );
|
||||
char* (*get_ali_secret)( void );
|
||||
|
||||
/* RTC */
|
||||
void (*MicoRtcInitialize)( void );
|
||||
OSStatus (*MicoRtcGetTime)( mico_rtc_time_t* time );
|
||||
OSStatus (*MicoRtcSetTime)( mico_rtc_time_t* time );
|
||||
struct tm* (*localtime)( const time_t * time );
|
||||
char * (*asctime)( const struct tm *tm );
|
||||
|
||||
int (*wifi_set_country)( int country );
|
||||
int (*switch_active_firmrware)( void );
|
||||
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 );
|
||||
|
||||
/* LwIP */
|
||||
lwip_api_t *lwip_apis;
|
||||
|
||||
/* FreeRTOS */
|
||||
|
||||
/* PWM */
|
||||
pwm_api_t *pwm_apis;
|
||||
|
||||
/* WDG */
|
||||
wdg_api_t *wdg_apis;
|
||||
|
||||
int (*ssl_get_fd)( const void* ssl );
|
||||
|
||||
void (*get_random_sequence)( unsigned char *buf, unsigned int size );
|
||||
adc_api_t *adc_apis;
|
||||
i2c_api_t *i2c_apis;
|
||||
spi_api_t *spi_apis;
|
||||
gtimer_api_t *gtimer_apis;
|
||||
|
||||
int (*ssl_set_loggingcb)( ssl_Logging_cb f );
|
||||
int (*wlan_inject_frame)( const uint8_t *buff, size_t len );
|
||||
int (*wlan_rx_mgmt_indication)( const enum wlan_bss_type bss_type,
|
||||
const uint32_t mgmt_subtype_mask,
|
||||
void (*rx_mgmt_callback)( const enum wlan_bss_type
|
||||
bss_type,
|
||||
const uint8_t *frame,
|
||||
const uint16_t len ) );
|
||||
int (*wlan_remain_on_channel)( const bool status, const uint8_t channel,
|
||||
const uint32_t duration );
|
||||
|
||||
int (*wifi_bridge_mode_enable)( bool hidden_ssid );
|
||||
int (*wifi_bridge_mode_disable)( void );
|
||||
|
||||
int (*send_easylink_minus)( uint32_t ip, char *ssid, char *key );
|
||||
|
||||
int (*ssl_socket)( void* ssl );
|
||||
int (*mico_wlan_get_channel)(void);
|
||||
|
||||
int (*ssl_pending)(void* ssl);
|
||||
int (*ssl_get_error)(void* ssl, int ret);
|
||||
void (*ssl_set_using_nonblock)(void* ssl, int nonblock);
|
||||
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);
|
||||
} mico_api_t;
|
||||
|
||||
typedef struct user_api_struct
|
||||
{
|
||||
uint32_t len;
|
||||
uint16_t reserved;
|
||||
uint16_t crc16;
|
||||
uint32_t magic_num;
|
||||
uint32_t app_stack_size;
|
||||
uint32_t interface_version;
|
||||
char * version;
|
||||
char * user_app_version;
|
||||
char * PID;
|
||||
char * SN;
|
||||
mico_uart_t debug_uart;
|
||||
int debug_baudrate;
|
||||
|
||||
void (*user_app_in)( const mico_api_t *lib_api_t );
|
||||
void (*init_platform)( void );
|
||||
int (*application_start)( void );
|
||||
|
||||
/* callback functions */
|
||||
void (*ApListCallback)( ScanResult *pApList );
|
||||
void (*ApListAdvCallback)( ScanResult_adv *pApAdvList );
|
||||
void (*WifiStatusHandler)( WiFiEvent status );
|
||||
void (*connected_ap_info)( apinfo_adv_t *ap_info, char *key, int key_len );
|
||||
void (*NetCallback)( IPStatusTypedef *pnet );
|
||||
void (*RptConfigmodeRslt)( network_InitTypeDef_st *nwkpara );
|
||||
void (*easylink_user_data_result)( int datalen, char*data );
|
||||
void (*socket_connected)( int fd );
|
||||
void (*dns_ip_set)( uint8_t *hostname, uint32_t ip );
|
||||
void (*join_fail)( OSStatus err );
|
||||
void (*wifi_reboot_event)( void );
|
||||
void (*mico_rtos_stack_overflow)( char *taskname );
|
||||
const platform_peripherals_pinmap_t *pinmaps;
|
||||
const mico_gpio_init_t *gpio_init;
|
||||
const uint8_t stdio_break_in;
|
||||
} user_api_t;
|
||||
|
||||
typedef enum {
|
||||
/* CHANNEL PLAN */
|
||||
MICO_COUNTRY_WORLD1, // 0x20
|
||||
MICO_COUNTRY_ETSI1, // 0x21
|
||||
MICO_COUNTRY_FCC1, // 0x22
|
||||
MICO_COUNTRY_MKK1, // 0x23
|
||||
MICO_COUNTRY_ETSI2, // 0x24
|
||||
MICO_COUNTRY_FCC2, // 0x2A
|
||||
MICO_COUNTRY_WORLD2, // 0x47
|
||||
MICO_COUNTRY_MKK2, // 0x58
|
||||
|
||||
/* SPECIAL */
|
||||
MICO_COUNTRY_WORLD, // WORLD1
|
||||
MICO_COUNTRY_EU, // ETSI1
|
||||
|
||||
/* JAPANESE */
|
||||
MICO_COUNTRY_JP, // MKK1
|
||||
|
||||
/* FCC , 19 countries*/
|
||||
MICO_COUNTRY_AS, // FCC2
|
||||
MICO_COUNTRY_BM,
|
||||
MICO_COUNTRY_CA,
|
||||
MICO_COUNTRY_DM,
|
||||
MICO_COUNTRY_DO,
|
||||
MICO_COUNTRY_FM,
|
||||
MICO_COUNTRY_GD,
|
||||
MICO_COUNTRY_GT,
|
||||
MICO_COUNTRY_GU,
|
||||
MICO_COUNTRY_HT,
|
||||
MICO_COUNTRY_MH,
|
||||
MICO_COUNTRY_MP,
|
||||
MICO_COUNTRY_NI,
|
||||
MICO_COUNTRY_PA,
|
||||
MICO_COUNTRY_PR,
|
||||
MICO_COUNTRY_PW,
|
||||
MICO_COUNTRY_TW,
|
||||
MICO_COUNTRY_US,
|
||||
MICO_COUNTRY_VI,
|
||||
|
||||
/* others, ETSI */
|
||||
MICO_COUNTRY_AD, // ETSI1
|
||||
MICO_COUNTRY_AE,
|
||||
MICO_COUNTRY_AF,
|
||||
MICO_COUNTRY_AI,
|
||||
MICO_COUNTRY_AL,
|
||||
MICO_COUNTRY_AM,
|
||||
MICO_COUNTRY_AN,
|
||||
MICO_COUNTRY_AR,
|
||||
MICO_COUNTRY_AT,
|
||||
MICO_COUNTRY_AU,
|
||||
MICO_COUNTRY_AW,
|
||||
MICO_COUNTRY_AZ,
|
||||
MICO_COUNTRY_BA,
|
||||
MICO_COUNTRY_BB,
|
||||
MICO_COUNTRY_BD,
|
||||
MICO_COUNTRY_BE,
|
||||
MICO_COUNTRY_BF,
|
||||
MICO_COUNTRY_BG,
|
||||
MICO_COUNTRY_BH,
|
||||
MICO_COUNTRY_BL,
|
||||
MICO_COUNTRY_BN,
|
||||
MICO_COUNTRY_BO,
|
||||
MICO_COUNTRY_BR,
|
||||
MICO_COUNTRY_BS,
|
||||
MICO_COUNTRY_BT,
|
||||
MICO_COUNTRY_BY,
|
||||
MICO_COUNTRY_BZ,
|
||||
MICO_COUNTRY_CF,
|
||||
MICO_COUNTRY_CH,
|
||||
MICO_COUNTRY_CI,
|
||||
MICO_COUNTRY_CL,
|
||||
MICO_COUNTRY_CN,
|
||||
MICO_COUNTRY_CO,
|
||||
MICO_COUNTRY_CR,
|
||||
MICO_COUNTRY_CX,
|
||||
MICO_COUNTRY_CY,
|
||||
MICO_COUNTRY_CZ,
|
||||
MICO_COUNTRY_DE,
|
||||
MICO_COUNTRY_DK,
|
||||
MICO_COUNTRY_DZ,
|
||||
MICO_COUNTRY_EC,
|
||||
MICO_COUNTRY_EE,
|
||||
MICO_COUNTRY_EG,
|
||||
MICO_COUNTRY_ES,
|
||||
MICO_COUNTRY_ET,
|
||||
MICO_COUNTRY_FI,
|
||||
MICO_COUNTRY_FR,
|
||||
MICO_COUNTRY_GB,
|
||||
MICO_COUNTRY_GE,
|
||||
MICO_COUNTRY_GF,
|
||||
MICO_COUNTRY_GH,
|
||||
MICO_COUNTRY_GL,
|
||||
MICO_COUNTRY_GP,
|
||||
MICO_COUNTRY_GR,
|
||||
MICO_COUNTRY_GY,
|
||||
MICO_COUNTRY_HK,
|
||||
MICO_COUNTRY_HN,
|
||||
MICO_COUNTRY_HR,
|
||||
MICO_COUNTRY_HU,
|
||||
MICO_COUNTRY_ID,
|
||||
MICO_COUNTRY_IE,
|
||||
MICO_COUNTRY_IL,
|
||||
MICO_COUNTRY_IN,
|
||||
MICO_COUNTRY_IQ,
|
||||
MICO_COUNTRY_IR,
|
||||
MICO_COUNTRY_IS,
|
||||
MICO_COUNTRY_IT,
|
||||
MICO_COUNTRY_JM,
|
||||
MICO_COUNTRY_JO,
|
||||
MICO_COUNTRY_KE,
|
||||
MICO_COUNTRY_KH,
|
||||
MICO_COUNTRY_KN,
|
||||
MICO_COUNTRY_KP,
|
||||
MICO_COUNTRY_KR,
|
||||
MICO_COUNTRY_KW,
|
||||
MICO_COUNTRY_KY,
|
||||
MICO_COUNTRY_KZ,
|
||||
MICO_COUNTRY_LA,
|
||||
MICO_COUNTRY_LB,
|
||||
MICO_COUNTRY_LC,
|
||||
MICO_COUNTRY_LI,
|
||||
MICO_COUNTRY_LK,
|
||||
MICO_COUNTRY_LR,
|
||||
MICO_COUNTRY_LS,
|
||||
MICO_COUNTRY_LT,
|
||||
MICO_COUNTRY_LU,
|
||||
MICO_COUNTRY_LV,
|
||||
MICO_COUNTRY_MA,
|
||||
MICO_COUNTRY_MC,
|
||||
MICO_COUNTRY_MD,
|
||||
MICO_COUNTRY_ME,
|
||||
MICO_COUNTRY_MF,
|
||||
MICO_COUNTRY_MK,
|
||||
MICO_COUNTRY_MN,
|
||||
MICO_COUNTRY_MO,
|
||||
MICO_COUNTRY_MQ,
|
||||
MICO_COUNTRY_MR,
|
||||
MICO_COUNTRY_MT,
|
||||
MICO_COUNTRY_MU,
|
||||
MICO_COUNTRY_MV,
|
||||
MICO_COUNTRY_MW,
|
||||
MICO_COUNTRY_MX,
|
||||
MICO_COUNTRY_MY,
|
||||
MICO_COUNTRY_NG,
|
||||
MICO_COUNTRY_NL,
|
||||
MICO_COUNTRY_NO,
|
||||
MICO_COUNTRY_NP,
|
||||
MICO_COUNTRY_NZ,
|
||||
MICO_COUNTRY_OM,
|
||||
MICO_COUNTRY_PE,
|
||||
MICO_COUNTRY_PF,
|
||||
MICO_COUNTRY_PG,
|
||||
MICO_COUNTRY_PH,
|
||||
MICO_COUNTRY_PK,
|
||||
MICO_COUNTRY_PL,
|
||||
MICO_COUNTRY_PM,
|
||||
MICO_COUNTRY_PT,
|
||||
MICO_COUNTRY_PY,
|
||||
MICO_COUNTRY_QA,
|
||||
MICO_COUNTRY_RS,
|
||||
MICO_COUNTRY_RU,
|
||||
MICO_COUNTRY_RW,
|
||||
MICO_COUNTRY_SA,
|
||||
MICO_COUNTRY_SE,
|
||||
MICO_COUNTRY_SG,
|
||||
MICO_COUNTRY_SI,
|
||||
MICO_COUNTRY_SK,
|
||||
MICO_COUNTRY_SN,
|
||||
MICO_COUNTRY_SR,
|
||||
MICO_COUNTRY_SV,
|
||||
MICO_COUNTRY_SY,
|
||||
MICO_COUNTRY_TC,
|
||||
MICO_COUNTRY_TD,
|
||||
MICO_COUNTRY_TG,
|
||||
MICO_COUNTRY_TH,
|
||||
MICO_COUNTRY_TN,
|
||||
MICO_COUNTRY_TR,
|
||||
MICO_COUNTRY_TT,
|
||||
MICO_COUNTRY_TZ,
|
||||
MICO_COUNTRY_UA,
|
||||
MICO_COUNTRY_UG,
|
||||
MICO_COUNTRY_UY,
|
||||
MICO_COUNTRY_UZ,
|
||||
MICO_COUNTRY_VC,
|
||||
MICO_COUNTRY_VE,
|
||||
MICO_COUNTRY_VN,
|
||||
MICO_COUNTRY_VU,
|
||||
MICO_COUNTRY_WF,
|
||||
MICO_COUNTRY_WS,
|
||||
MICO_COUNTRY_YE,
|
||||
MICO_COUNTRY_YT,
|
||||
MICO_COUNTRY_ZA,
|
||||
MICO_COUNTRY_ZW,
|
||||
|
||||
MICO_COUNTRY_MAX
|
||||
|
||||
}mico_country_code_t;
|
||||
|
||||
#endif
|
||||
263
mico-os/platform/MCU/MX1290/moc/moc_api_sep.h
Normal file
263
mico-os/platform/MCU/MX1290/moc/moc_api_sep.h
Normal file
@@ -0,0 +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);
|
||||
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);
|
||||
Reference in New Issue
Block a user