This commit is contained in:
lmx
2025-10-29 13:10:02 +08:00
commit 49a07fa419
2284 changed files with 642060 additions and 0 deletions

View File

@ -0,0 +1,86 @@
#ifndef SYS_APPLICATION_H
#define SYS_APPLICATION_H
#include "typedef.h"
#include "generic/list.h"
#include "system/event.h"
#define ACTION_BACK 0x0a1b2c00
#define ACTION_STOP 0x0a1b2c01
#define ACTION_DO_NOTHING 0x0a1b2c02
#define ACTION_TONE_PLAY 0x0a1b2c03
#define ACTION_CLASS_MASK 0xfffff000
enum app_state {
APP_STA_CREATE,
APP_STA_START,
APP_STA_PAUSE,
APP_STA_RESUME,
APP_STA_STOP,
APP_STA_DESTROY,
};
struct application;
struct intent {
const char *name;
int action;
const char *data;
u32 exdata;
};
struct application_operation {
int (*state_machine)(struct application *, enum app_state, struct intent *);
int (*event_handler)(struct application *, struct sys_event *);
};
struct application {
u8 state;
int action;
char *data;
const char *name;
struct list_head entry;
void *private_data;
const struct application_operation *ops;
};
#define REGISTER_APPLICATION(at) \
static struct application at sec(.app)
#define init_intent(it) \
do { \
(it)->name = NULL; \
(it)->action= 0; \
(it)->data = NULL; \
(it)->exdata = 0; \
}while (0)
void register_app_event_handler(int (*handler)(struct sys_event *));
struct application *get_current_app();
struct application *get_prev_app();
void app_core_back_to_prev_app();
int start_app(struct intent *it);
int start_app_async(struct intent *it, void (*callback)(void *p, int err), void *p);
#endif

View File

@ -0,0 +1,20 @@
#ifndef SYS_APP_MSG_H
#define SYS_APP_MSG_H
//app自定义消息发送接口
int app_task_put_usr_msg(int msg, int arg_num, ...);
//app消息获取接口(block参数为0表示内部pend1直接返回)
void app_task_get_msg(int *msg, int msg_size, int block);
//app按键消息发送接口
int app_task_put_key_msg(int msg, int value);
//app清理按键消息接口
void app_task_clear_key_msg();
#endif

View File

@ -0,0 +1,141 @@
/*************************************************************/
/** @file: usb_device.h
@brief: USB 从机驱动重写加入iAP协议
@details:
@author: Bingquan Cai
@date: 2013-10-11,09:34
@note:
*/
/*************************************************************/
#ifndef _IAP_H_
#define _IAP_H_
#include "generic/typedef.h"
// #include "string.h"
// #include "usb/usb_slave_api.h"
#define IAP2_LINK_EN 1
#define IAP_USE_USB_HID_EN 1
//USB
#define MAXP_SIZE_INTERRUPT_IN 0x40
//IIC crack
#define AUTHENTICATION_CONTROL_STATUS 0x10
#define SIGNATURE_DATA_LENGTH 0x11
#define SIGNATURE_DATA 0x12
#define CHALLENGE_DATA_LENGTH 0x20
#define CHALLENGE_DATA 0x21
#define ACCESSORY_CERTIFICATE_DATA_LENGTH 0x30
#define ACCESSORY_CERTIFICATE_DATA 0x31
//iAP1 and iAP2 COMMON
#define IAP2_VERSIONS 0x02
#define IAP1_VERSIONS 0x01
#define DEFAULT_SEQUENCE_NUM 0x0
#define EXTRA_SEQUENCE_NUM 0x1
//"Dock speaker"
#define ACCESSORY_NAME 0x44, 0x6f, 0x63, 0x6b, 0x20, 0x73, 0x70, 0x65, 0x61, 0x6b, 0x65, 0x72, 0x00
//"IPDLI13"
#define ACCESSORY_MODEL_IDENTIFIER 0x49, 0x50, 0x44, 0x4c, 0x49, 0x31, 0x33, 0x00
//"I want it"
#define ACCESSORY_MANUFACTURER 0x49, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20, 0x69, 0x74, 0x00
//"iAP Interface"
#define ACCESSORY_SERIALNUMBER 0x69, 0x41, 0x50, 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x00
//< hid
#define HID_PREV_FILE USB_AUDIO_PREFILE
#define HID_NEXT_FILE USB_AUDIO_NEXTFILE
#define HID_PP USB_AUDIO_PP
#define HID_PLAY USB_AUDIO_PLAY
#define HID_PAUSE USB_AUDIO_PAUSE
#define HID_VOL_DOWN USB_AUDIO_VOLDOWN
#define HID_VOL_UP USB_AUDIO_VOLUP
//<iap printf
#include "uart.h"
#define IAP_CHIP_PRINTF
#ifdef IAP_CHIP_PRINTF
#define iAP_deg_str(x) puts(x)
#define iAP_printf printf
#define iAP_printf_buf(x, y) put_buf(x, y)
#define iAP_put_u8hex(x) put_u8hex(x)
#define iAP_put_u16hex(x) put_u16hex(x)
#define iAP_put_u32hex(x) put_u32hex(x)
#else
#define iAP_deg_str(x)
#define iAP_printf(...)
#define iAP_printf_buf(x, y)
#define iAP_put_u8hex(x)
#define iAP_put_u16hex(x)
#define iAP_put_u32hex(x)
#endif
#define _xdata
// #define _data
#define _root
#define _no_init
#define _banked_func
///variable
typedef enum {
iAP_IDLE = 0,
iAP_INTERRUPT,
iAP_BULK_IN,
iAP_BULE_OUT,
} iAP_STATE;
enum {
NO_MFI_CHIP = 0,
MFI_PROCESS_READY,
MFI_PROCESS_STANDBY,
MFI_PROCESS_PASS,
IAP1_LINK_ERR,
IAP1_LINK_SUCC,
IAP2_LINK_ERR,
IAP2_LINK_SUCC,
};
//extern var
extern u8 chip_online_status;
extern u8 mfi_pass_status;
#define apple_mfi_chip_online_lib() chip_online_status
#define apple_link_disable() mfi_pass_status = MFI_PROCESS_STANDBY
#define apple_link_init() mfi_pass_status = MFI_PROCESS_STANDBY
#define apple_mfi_pass_ready_set_api() mfi_pass_status = MFI_PROCESS_READY
#define apple_hid_key_api(key) iap2_hid_key(key)
///outside call parameter
extern u8 *iAP_var_pRxBuf ;
extern u8 *iAP_var_pTxBuf ;
extern u16 iAP_var_wLength;
extern u8 iAP_send_pkt_self[0x40] ;
extern u8 iAP_receive_pkt_self[0x40] ;
///inside call
// void my_code_memcpy(u8 *s1, const u8 *s2, u16 len);
#define my_code_memcpy(x,y,z) memcpy(x,(u8 *)y,z)
// u8 my_memcmp(u8 *s1, const u8 *s2, u8 len);
#define my_code_memcmp(x,y,z) memcmp(x,(u8 *)y,z)
u8 iAP_support(void);
u8 apple_mfi_link(void *hdl);
void apple_mfi_unlink(void);
// #define iAP_host_online() (get_usb_online_status() & BIT(0))
// #define iAP_device_online() (get_usb_online_status() & BIT(1))
#define GET_U16L(x) (u8)(x)
#define GET_U16H(x) (u8)((u16)(x)>>8)
#define SW16(x) (((u16)(x) & 0x00ffU)<<8 | ((u16)(x) & 0xff00U)>>8)
#endif /* _IAP_H_ */

View File

@ -0,0 +1,178 @@
#ifndef BANK_SWITCH_H
#define BANK_SWITCH_H
#ifdef CONFIG_CODE_BANK_ENABLE
#define _BANK_ENTRY(num) __attribute__((section(".bank.code."#num))) __attribute__((banknum(num)))
#define __BANK_ENTRY(num) _BANK_ENTRY(num)
#define _BANK_NUM(num) __attribute__((section(".bank.code."#num))) __attribute__((banknum(num)))
#define __BANK_NUM(num) _BANK_NUM(num)
#define __BANK_COMMON() __attribute__((section(".common")))
#else
#define __BANK_ENTRY(num)
#define __BANK_NUM(num)
#endif
#ifdef CONFIG_BANK_COMM
#define __BANK_EDR_RX __BANK_COMMON()
#define __BANK_EDR_TX __BANK_COMMON()
#define __BANK_TWS_LINK __BANK_COMMON()
#define __BANK_EDR_FRAME __BANK_COMMON()
#else
#define __BANK_EDR_RX
#define __BANK_EDR_TX
#define __BANK_TWS_LINK
#define __BANK_EDR_FRAME
#endif
#ifdef CONFIG_BANK_NUM_INIT
#define __BANK_INIT_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_INIT)
#define __BANK_INIT __BANK_NUM(CONFIG_BANK_NUM_INIT)
#else
#define __BANK_INIT_ENTRY
#define __BANK_INIT
#endif
#ifdef CONFIG_BANK_NUM_RF
#define __BANK_RF_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_RF)
#define __BANK_RF __BANK_NUM(CONFIG_BANK_NUM_RF)
#else
#define __BANK_RF_ENTRY
#define __BANK_RF
#endif
#ifdef CONFIG_BANK_NUM_RF_TRIM
#define __BANK_RF_TRIM __BANK_NUM(CONFIG_BANK_NUM_RF_TRIM)
#else
#define __BANK_RF_TRIM
#endif
#ifdef CONFIG_BANK_NUM_DUT
#define __BANK_DUT_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_DUT)
#define __BANK_DUT __BANK_NUM(CONFIG_BANK_NUM_DUT)
#else
#define __BANK_DUT_ENTRY
#define __BANK_DUT
#endif
#ifdef CONFIG_BANK_NUM_ECDH
#define __BANK_ECDH_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_ECDH)
#define __BANK_ECDH __BANK_NUM(CONFIG_BANK_NUM_ECDH)
#else
#define __BANK_ECDH_ENTRY
#define __BANK_ECDH
#endif
#ifdef CONFIG_BANK_NUM_ENC
#define __BANK_ENC_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_ENC)
#define __BANK_ENC __BANK_NUM(CONFIG_BANK_NUM_ENC)
#else
#define __BANK_ENC_ENTRY
#define __BANK_ENC
#endif
#ifdef CONFIG_BANK_NUM_A2DP
#define __BANK_A2DP_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_A2DP)
#define __BANK_A2DP __BANK_NUM(CONFIG_BANK_NUM_A2DP)
#else
#define __BANK_A2DP_ENTRY
#define __BANK_A2DP
#endif
#ifdef CONFIG_BANK_NUM_AVCTP
#define __BANK_AVCTP_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_AVCTP)
#define __BANK_AVCTP __BANK_NUM(CONFIG_BANK_NUM_AVCTP)
#else
#define __BANK_AVCTP_ENTRY
#define __BANK_AVCTP
#endif
#ifdef CONFIG_BANK_NUM_RFCOMM
#define __BANK_RFCOMM_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_RFCOMM)
#define __BANK_RFCOMM __BANK_NUM(CONFIG_BANK_NUM_RFCOMM)
#else
#define __BANK_RFCOMM_ENTRY
#define __BANK_RFCOMM
#endif
#ifdef CONFIG_BANK_NUM_SDP
#define __BANK_SDP_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_SDP)
#define __BANK_SDP __BANK_NUM(CONFIG_BANK_NUM_SDP)
#else
#define __BANK_SDP_ENTRY
#define __BANK_SDP
#endif
#ifdef CONFIG_BANK_NUM_BT_HID
#define __BANK_BT_HID_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_BT_HID)
#define __BANK_BT_HID __BANK_NUM(CONFIG_BANK_NUM_BT_HID)
#else
#define __BANK_BT_HID_ENTRY
#define __BANK_BT_HID
#endif
#ifdef CONFIG_BANK_NUM_BLE
#define __BANK_BLE_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_BLE)
#define __BANK_BLE __BANK_NUM(CONFIG_BANK_NUM_BLE)
#else
#define __BANK_BLE_ENTRY
#define __BANK_BLE
#endif
#ifdef CONFIG_BANK_NUM_TWS_BLE
#define __BANK_TWS_BLE_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_TWS_BLE)
#define __BANK_TWS_BLE __BANK_NUM(CONFIG_BANK_NUM_TWS_BLE)
#else
#define __BANK_TWS_BLE_ENTRY
#define __BANK_TWS_BLE
#endif
#ifdef CONFIG_BANK_NUM_TONE
#define __BANK_TONE_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_TONE)
#define __BANK_TONE __BANK_NUM(CONFIG_BANK_NUM_TONE)
#else
#define __BANK_TONE_ENTRY
#define __BANK_TONE
#endif
#ifdef CONFIG_BANK_NUM_LMP_SLAVE
#define __BANK_LMP_SLAVE_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_LMP_SLAVE)
#define __BANK_LMP_SLAVE __BANK_NUM(CONFIG_BANK_NUM_LMP_SLAVE)
#else
#define __BANK_LMP_SLAVE_ENTRY
#define __BANK_LMP_SLAVE
#endif
#ifdef CONFIG_BANK_NUM_LMP_MASTER
#define __BANK_LMP_MASTER_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_LMP_MASTER)
#define __BANK_LMP_MASTER __BANK_NUM(CONFIG_BANK_NUM_LMP_MASTER)
#else
#define __BANK_LMP_MASTER_ENTRY
#define __BANK_LMP_MASTER
#endif
#ifdef CONFIG_BANK_NUM_CLOCK
#define __BANK_CLOCK_ENTRY __BANK_ENTRY(CONFIG_BANK_NUM_CLOCK)
#define __BANK_CLOCK __BANK_NUM(CONFIG_BANK_NUM_CLOCK)
#else
#define __BANK_CLOCK_ENTRY
#define __BANK_CLOCK
#endif
void load_overlay_code(int num);
void bank_syscall_entry(void);
void load_common_code(void);
#endif

72
include_lib/system/boot.h Normal file
View File

@ -0,0 +1,72 @@
#ifndef __BOOT_H__
#define __BOOT_H__
struct vm_info {
#if (USE_SDFILE_NEW == 1)
u8 align; //from uboot, 按 n * 256 对齐
#endif
u32 vm_saddr; //from sdfile, flash addr
u32 vm_res; //reverse_bytes
u32 vm_size; //from sdfile
};
struct sfc_info {
u32 sfc_base_addr; //flash memory addr, from uboot
u32 app_addr; //cpu logic addr, from uboot
};
#if (USE_SDFILE_NEW == 1)
struct bt_mac_addr {
u8 value[6];
u16 value_crc;
};
typedef struct _boot_info {
struct vm_info vm;
struct sfc_info sfc;
u32 flash_size; //from uboot
u16 chip_id; //from uboot
u16 trim_value; //from uboot
struct bt_mac_addr mac;
} BOOT_INFO;
//=====================================
struct flash_head {
u16 crc;
u16 size4burner;
u8 vid[4]; //u32 vm_eaddr;
u32 FlashSize;
u8 FsVersion; //flash文件结构
u8 align; //对齐 n * 256
u8 res;
u8 SpecialOptFlag;
u8 pid[16];
};
typedef struct boot_device_info {
struct flash_head *fs_info;
struct sfc_info sfc;
u16 chip_id; //from uboot
u16 trim_value; //from uboot
u8 bt_mac_addr[8];
} BOOT_DEVICE_INFO;
#else
typedef struct _boot_info {
struct vm_info vm;
struct sfc_info sfc;
u32 flash_size; //from uboot
u32 size4burner; //from uboot
u16 chip_id; //from uboot
u16 trim_value; //from uboot
} BOOT_INFO;
#endif /* #if (USE_SDFILE_NEW == 1) */
extern BOOT_INFO boot_info;
#endif

View File

@ -0,0 +1,30 @@
/*********************************************************************************************
* Filename : config_interface.h
* Description :
* Author : Bingquan
* Email : bingquan_cai@zh-jieli.com
* Last modifiled : 2019-01-10 09:55
* Copyright:(c)JIELI 2011-2019 @ , All Rights Reserved.
*********************************************************************************************/
#ifndef _CONFIG_INTERFACE_H_
#define _CONFIG_INTERFACE_H_
#include "config/config_transport.h"
#include "config/config_target.h"
//配置工具 0:旧工具 1:新工具
#define NEW_CONFIG_TOOL 1 //
void config_layer_init(const ci_transport_t *transport, void *config);
void *config_load(int id);
void ci_send_packet(u32 id, u8 *packet, int size);
#endif

View File

@ -0,0 +1,43 @@
/*********************************************************************************************
* Filename : config_target.h
* Description :
* Author : Bingquan
* Email : bingquan_cai@zh-jieli.com
* Last modifiled : 2019-01-09 19:28
* Copyright:(c)JIELI 2011-2017 @ , All Rights Reserved.
*********************************************************************************************/
#ifndef _CONFIG_TARGET_H_
#define _CONFIG_TARGET_H_
#include "typedef.h"
#define EQ_CONFIG_ID 0x0005
#define EFFECTS_CONFIG_ID 0x0006
#define AEC_CONFIG_ID 0x0008
typedef void (*ci_packet_handler_t)(uint8_t *packet, uint16_t size);
struct config_target {
u16 id;
ci_packet_handler_t callback;
};
#define REGISTER_CONFIG_TARGET(target) \
const struct config_target target sec(.config_target)
extern const struct config_target config_target_begin[];
extern const struct config_target config_target_end[];
#define list_for_each_config_target(p) \
for (p = config_target_begin; p < config_target_end; p++)
#endif

View File

@ -0,0 +1,93 @@
/*********************************************************************************************
* Filename : config_transport.h
* Description : Config Interface
* Author : Bingquan
* Email : bingquan_cai@zh-jieli.com
* Last modifiled : 2019-01-07 14:33
* Copyright:(c)JIELI 2011-2017 @ , All Rights Reserved.
*********************************************************************************************/
#ifndef _CI_TRANSPORT_H
#define _CI_TRANSPORT_H
#include "typedef.h"
/* CI packet types */
typedef struct {
/**
* transport name
*/
const char *name;
/**
* init transport
* @param transport_config
*/
void (*init)(const void *transport_config);
/**
* open transport connection
*/
int (*open)(void);
/**
* close transport connection
*/
int (*close)(void);
/**
* register packet handler for CI packets
*/
void (*register_packet_handler)(void (*handler)(const u8 *packet, int size));
/**
* support async transport layers, e.g. IRQ driven without buffers
*/
int (*can_send_packet_now)(uint8_t packet_type);
/**
* send packet
*/
int (*send_packet)(const u8 *packet, int size);
/**
* extension for UART transport implementations
*/
int (*set_baudrate)(uint32_t baudrate);
} ci_transport_t;
typedef enum {
CI_TRANSPORT_CONFIG_UART,
CI_TRANSPORT_CONFIG_USB,
CI_TRANSPORT_CONFIG_BLE,
} ci_transport_config_type_t;
typedef struct {
ci_transport_config_type_t type;
} ci_transport_config_t;
typedef struct {
ci_transport_config_type_t type; // == CI_TRANSPORT_CONFIG_UART
uint32_t baudrate_init; // initial baud rate
uint32_t baudrate_main; // = 0: same as initial baudrate
int flowcontrol; //
const char *device_name;
} ci_transport_config_uart_t;
typedef struct {
//head
u16 id;
u16 length;
u8 payload[0];
} _GNU_PACKED_ ci_packet_t;
#define CI_FORMAT_HEAD sizeof(ci_packet_t)
const ci_transport_t *ci_transport_uart_instance(void);
#endif

View File

@ -0,0 +1,34 @@
#ifndef DATABASE_H
#define DATABASE_H
#include "typedef.h"
struct db_table {
const char *name;
u8 value_bits;
int value;
};
int db_select_buffer(u8 index, char *buffer, int len);
int db_update_buffer(u8 index, char *buffer, int len);
int db_create(const char *store_dev);
int db_create_table(const struct db_table *table, int num);
u32 db_select(const char *table);
int db_update(const char *table, u32 value);
int db_flush();
int db_reset();
int db_erase();
#endif

159
include_lib/system/debug.h Normal file
View File

@ -0,0 +1,159 @@
#ifndef _DEBUG_H_
#define _DEBUG_H_
#include "asm/cpu.h"
#include "generic/typedef.h"
// -- output terminal color
#define RedBold "\033[31;1m" // 红色加粗
#define RedBoldBlink "\033[31;1;5m" // 红色加粗、闪烁
#define GreenBold "\033[32;1m" // 红色加粗
#define GreenBoldBlink "\033[32;1;5m" // 红色加粗、闪烁
#define YellowBold "\033[33;1m" // 红色加粗
#define YellowBoldBlink "\033[33;1;5m" // 红色加粗、闪烁
#define BlueBold "\033[34;1m" // 蓝色加粗
#define BlueBoldBlink "\033[34;1;5m" // 蓝色加粗、闪烁
#define PurpleBold "\033[35;1m" // 紫色加粗
#define PurpleBoldBlink "\033[35;1;5m" // 紫色加粗、闪烁
#define DGreenBold "\033[36;1m" // 红色加粗
#define DGreenBoldBlink "\033[36;1;5m" // 红色加粗、闪烁
#define WhiteBold "\033[37;1m" // 红色加粗
#define WhiteBoldBlink "\033[37;1;5m" // 红色加粗、闪烁
#define Reset "\033[0;25m" // 颜色复位
#define LOG_ASSERT_ENABLE
void printf_buf(u8 *buf, u32 len);
#define PRINTF(format, ...) printf(format, ## __VA_ARGS__)
#define LOG_VERBOSE v
#define LOG_INFO i
#define LOG_DEBUG d
#define LOG_WARN w
#define LOG_ERROR e
#define LOG_CHAR c
#define _STR(x) #x
#define STR(x) "["_STR(x)"]"
#define _LOG_TAG_CONST_DECLARE(level, name) extern const char log_tag_const_##level##_##name
#define LOG_TAG_CONST_DECLARE(level, name) _LOG_TAG_CONST_DECLARE(level, name)
#define ___LOG_IS_ENABLE(level, name) (log_tag_const_##level##_##name)
#define __LOG_IS_ENABLE(level, name) ___LOG_IS_ENABLE(level, name)
#define _LOG_IS_ENABLE(level) __LOG_IS_ENABLE(level, LOG_TAG_CONST)
#ifdef LOG_TAG_CONST
LOG_TAG_CONST_DECLARE(LOG_VERBOSE, LOG_TAG_CONST);
LOG_TAG_CONST_DECLARE(LOG_INFO, LOG_TAG_CONST);
LOG_TAG_CONST_DECLARE(LOG_DEBUG, LOG_TAG_CONST);
LOG_TAG_CONST_DECLARE(LOG_WARN, LOG_TAG_CONST);
LOG_TAG_CONST_DECLARE(LOG_ERROR, LOG_TAG_CONST);
LOG_TAG_CONST_DECLARE(LOG_CHAR, LOG_TAG_CONST);
#define _LOG_TAG STR(LOG_TAG_CONST)
#define LOG_IS_ENABLE(level) _LOG_IS_ENABLE(level)
#else
#define _LOG_TAG LOG_TAG
#define LOG_IS_ENABLE(x) 1
#endif
#define LOG_BY_MACRO 1
#define LOG_BY_CONST 2
// #define LOG_MODE LOG_BY_MACRO
#define LOG_MODE LOG_BY_CONST
/*
* LOG 通过宏控制
*/
#if (LOG_MODE == LOG_BY_MACRO)
#ifdef LOG_INFO_ENABLE
#define log_info(format, ...) PRINTF("[Info] :" _LOG_TAG format "\r\n", ## __VA_ARGS__)
#else
#define log_info(...)
#endif
#ifdef LOG_DEBUG_ENABLE
#define log_debug(format, ...) PRINTF("[Debug] :" _LOG_TAG format "\r\n", ## __VA_ARGS__)
#define log_debug_hexdump(x, y) printf_buf(x, y)
#else
#define log_debug(...)
#define log_debug_hexdump(x, y)
#endif
#ifdef LOG_ERROR_ENABLE
#define log_error(format, ...) PRINTF("<Error> :" _LOG_TAG format "\r\n", ## __VA_ARGS__)
#define log_error_hexdump(x, y) printf_buf(x, y)
#else
#define log_error(...)
#define log_error_hexdump(...)
#endif
#ifdef LOG_DUMP_ENABLE
#define log_info_hexdump(x,y) printf_buf(x,y)
#else
#define log_info_hexdump(...)
#endif
#ifdef LOG_CHAR_ENABLE
#define log_char(x) putchar(x)
#else
#define log_char(x)
#endif
/*
* LOG 通过常量控制
*/
#elif (LOG_MODE == LOG_BY_CONST)
#define log_info(format, ...) \
if (LOG_IS_ENABLE(LOG_INFO)) \
log_print(__LOG_INFO,NULL,"[Info]: " _LOG_TAG format "\r\n", ## __VA_ARGS__)
#define log_info_hexdump(x, y) \
if (LOG_IS_ENABLE(LOG_INFO)) \
printf_buf(x, y)
#define log_debug(format, ...) \
if (LOG_IS_ENABLE(LOG_DEBUG)) \
log_print(__LOG_DEBUG,NULL,"[Debug]: " _LOG_TAG format "\r\n", ## __VA_ARGS__)
#define log_debug_hexdump(x, y) \
if (LOG_IS_ENABLE(LOG_DEBUG)) \
printf_buf(x, y)
#define log_error(format, ...) \
if (LOG_IS_ENABLE(LOG_ERROR)) \
log_print(__LOG_ERROR,NULL,"<Error>: " _LOG_TAG format "\r\n", ## __VA_ARGS__)
#define log_error_hexdump(x, y) \
if (LOG_IS_ENABLE(LOG_ERROR)) \
printf_buf(x, y)
#define log_char(x) \
if (LOG_IS_ENABLE(LOG_CHAR)) \
putchar(x)
#endif
#define traceSUPER_MODE() \
/*{int icfg, rets, reti; \
__asm__ volatile("%0 = icfg" : "=r"(icfg)); \
__asm__ volatile("%0 = rets" :"=r"(rets)); \
__asm__ volatile("%0 = reti" :"=r"(reti)); \
ASSERT(icfg & BIT(10), "icfg 0x%x/ rets 0x%x / reti 0x%x", icfg, rets, reti)}*/
void watchdog_close(void);
#endif//__DEBUG_LOG_H_

View File

@ -0,0 +1,38 @@
#ifndef DEVICE_ADKEY_H
#define DEVICE_ADKEY_H
#include "typedef.h"
#include "asm/adc_api.h"
#define ADKEY_MAX_NUM 10
struct adkey_platform_data {
u8 enable;
u8 adkey_pin;
u8 extern_up_en; //是否用外部上拉1用外部上拉 0用内部上拉10K
u32 ad_channel;
u16 ad_value[ADKEY_MAX_NUM];
u8 key_value[ADKEY_MAX_NUM];
};
struct adkey_rtcvdd_platform_data {
u8 enable;
u8 adkey_pin;
u8 adkey_num;
u32 ad_channel;
u32 extern_up_res_value; //是否用外部上拉1用外部上拉 0用内部上拉10K
u16 res_value[ADKEY_MAX_NUM]; //电阻值, 从 [大 --> 小] 配置
u8 key_value[ADKEY_MAX_NUM];
};
//ADKEY API:
extern int adkey_init(const struct adkey_platform_data *adkey_data);
extern u8 ad_get_key_value(void);
//RTCVDD ADKEY API:
extern int adkey_rtcvdd_init(const struct adkey_rtcvdd_platform_data *rtcvdd_adkey_data);
extern u8 adkey_rtcvdd_get_key_value(void);
#endif

View File

@ -0,0 +1,83 @@
#ifndef CHRDEV_H
#define CHRDEV_H
#include "generic/typedef.h"
#include "generic/list.h"
//#include "generic/ioctl.h"
#include "generic/atomic.h"
//#include "sys/task.h"
#include "device/ioctl_cmds.h"
struct dev_node;
struct device;
/**@struct device_operations
* @brief device_operations结构体 \n
* otg设备执行哪种类型的操作
*/
struct device_operations {
bool (*online)(const struct dev_node *node); ///<设备在线状态查询
int (*init)(const struct dev_node *node, void *); ///<设备初始化
int (*open)(const char *name, struct device **device, void *arg); ///<设备开启
int (*read)(struct device *device, void *buf, u32 len, u32); ///<读操作
int (*write)(struct device *device, void *buf, u32 len, u32); ///<写操作
int (*seek)(struct device *device, u32 offset, int orig); ///<设备搜索
int (*ioctl)(struct device *device, u32 cmd, u32 arg); ///<I/O控制
int (*close)(struct device *device); ///<设备关闭
};
struct dev_node {
const char *name;
const struct device_operations *ops;
void *priv_data;
};
struct device {
atomic_t ref;
void *private_data;
const struct device_operations *ops;
void *platform_data;
void *driver_data;
};
#define REGISTER_DEVICE(node) \
const struct dev_node node sec(.device)
#define REGISTER_DEVICES(node) \
const struct dev_node node[] sec(.device)
int devices_init();
bool dev_online(const char *name);
void *dev_open(const char *name, void *arg);
int dev_read(void *device, void *buf, u32 len);
int dev_write(void *device, void *buf, u32 len);
int dev_seek(void *device, u32 offset, int orig);
int dev_ioctl(void *device, int cmd, u32 arg);
int dev_close(void *device);
int dev_bulk_read(void *_device, void *buf, u32 offset, u32 len);
int dev_bulk_write(void *_device, void *buf, u32 offset, u32 len);
#endif

View File

@ -0,0 +1,190 @@
#ifndef __DEVICE_DRIVE_H__
#define __DEVICE_DRIVE_H__
#include "typedef.h"
#include "errno-base.h"
#include "ioctl.h"
#ifndef __UBOOT
#ifndef _MANGO_OS_
#define _MANGO_OS_
#endif
#endif
#ifdef _MANGO_OS_
#include "os/os_api.h"
#else
#ifndef __UBOOT
#ifndef _WIN_DEBUG_
#define _WIN_DEBUG_
#endif
#endif
#ifdef _WIN_DEBUG_
#include <pthread.h>
typedef pthread_mutex_t OS_MUTEX;
typedef u32 OS_ERR;
#define OS_ERR_NONE 0
#else
typedef u32 OS_MUTEX, OS_ERR;
#define OS_ERR_NONE 0
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
struct dev_mutex {
OS_MUTEX *write_mutex;
OS_MUTEX *read_mutex;
};
typedef enum _dev_type {
DEV_SDCRAD_0 = 0X10,
DEV_SDCRAD_1,
DEV_SDCRAD_2,
DEV_UDISK_H0,
DEV_UDISK_H1,
DEV_UDISK_F0,
DEV_NOR_FLASH,
DEV_NAND_FLASH,
DEV_STORAGE = 0x100,
DEV_LOGIC_DISK = 0x101,
DEV_USB_SLAVE,
DEV_USB_HOST,
DEV_HID = 0x200,
DEV_NET,
DEV_AUDIO,
DEV_ISP,
} dev_type;
// struct partition_table
// {
// int partition_addr;
// int partition_size;
// };
typedef struct DEV_IO {
const char name[8];
s32(*mount)(void *volatile parm);
s32(*unmount)();
s32(*read)(u8 *volatile buf, u32 addr, u32 len);
s32(*write)(u8 *volatile buf, u32 addr, u32 len);
s32(*ioctrl)(void *volatile parm, u32 cmd);
s32(*power)(u32 mod);
s32(*detect)(); //设备状态检测
struct dev_mutex *mutex;
dev_type device_type;
void *private_data;//设备私有属性,用来提供额外接口或者存储一些设备的特性
} dev_io_t;
//设备状态:
typedef enum dev_sta {
DEV_OFFLINE = 0, //--0 设备从在线切换到离线。
DEV_ONLINE = 1, //---1 设备从离线切换到在线。
DEV_HOLD = 2, //---2 其他值表示设备状态未改变。
DEV_POWER_ON = 0x10, // 0x10 开机
DEV_POWER_OFF, // 0x11 -关机
DEV_POWER_STANDBY, // 0x12 -待机
DEV_POWER_WAKEUP, // 0x13- 唤醒
} DEV_STA;
//设备错误代码:
typedef enum dev_err {
DEV_ERR_NONE = 0,
DEV_ERR_NOT_MOUNT,
DEV_ERR_OVER_CAPACITY,
DEV_ERR_UNKNOW_CLASS,
DEV_ERR_NOT_READY,//设备已经在线,但是没初始化完成
DEV_ERR_LUN,
DEV_ERR_TIMEOUT,
DEV_ERR_CMD_TIMEOUT,
DEV_ERR_READ_TIMEOUT,//0x08
DEV_ERR_WRITE_TIMEOUT,
DEV_ERR_OFFLINE,//0x0a
DEV_ERR_CRC,
DEV_ERR_CMD_CRC,
DEV_ERR_READ_CRC,
DEV_ERR_WRITE_CRC,
DEV_ERR_CONTROL_STALL,
DEV_ERR_RXSTALL,//0x10
DEV_ERR_TXSTALL,
DEV_ERR_CONTROL,
DEV_ERR_NOT_STORAGE,
DEV_ERR_INVALID_PATH,
DEV_ERR_INVALID_DATA,
DEV_ERR_OUTOFMEMORY,
DEV_ERR_HANDLE_FREE,
DEV_ERR_INVALID_HANDLE,//24
DEV_ERR_INVALID_BUF,
DEV_ERR_INUSE,
DEV_ERR_NO_READ,
DEV_ERR_NO_WRITE,
DEV_ERR_NO_IOCTL,
DEV_ERR_NO_POWER,
DEV_ERR_NOT_EXIST,
DEV_ERR_UNKNOW,
} DEV_ERR;
#define DEV_GENERAL_MAGIC 0xe0
//每个设备必须支持的命令
#define DEV_GET_STATUS _IOR(DEV_GENERAL_MAGIC,0xe0,u32) //获取设备状态在线、离线、power_on、power_off、standby、……
//设备不支持下面命令时返回 -ENOTTY
#define DEV_GET_BLOCK_SIZE _IOR(DEV_GENERAL_MAGIC,0xe1,u32) //获取存储设备的块大小
#define DEV_GET_BLOCK_NUM _IOR(DEV_GENERAL_MAGIC,0xe2,u32) //获取存储设备的块总数
#define DEV_GET_DEV_ID _IOR(DEV_GENERAL_MAGIC,0xe3,u32) //获取设备的ID。SD/TF 卡返回“sdtf”(0x73647466)
#define DEV_SECTOR_ERASE _IOW(DEV_GENERAL_MAGIC,0xe4,u32) //设备页擦除
#define DEV_BLOCK_ERASE _IOW(DEV_GENERAL_MAGIC,0xe5,u32) //设备块擦除
#define DEV_CHIP_ERASE _IOW(DEV_GENERAL_MAGIC,0xe6,u32) //设备擦除
#define DEV_GET_TYPE _IOR(DEV_GENERAL_MAGIC,0xe7,u32) //返回设备的dev_type
#define DEV_CHECK_WPSTA _IOR(DEV_GENERAL_MAGIC,0xe8,u32) //检测设备写保护状态,当参数为-1的时候返回设备的写包含状态0的时候解除写保护1的时候加上写保护
#define typecheck(type,x) \
({ type __dummy; \
typeof(x) __dummy2; \
(void)(&__dummy == &__dummy2); \
1; \
})
#ifndef time_after
#define time_after(a,b) (typecheck(u32, a) && \
typecheck(u32, b) && \
((s32)(b) - (s32)(a) < 0))
#endif
#ifndef time_before
#define time_before(a,b) time_after(b,a)
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,32 @@
#ifndef DEVICE_INCLUDES_H
#define DEVICE_INCLUDES_H
#include "device.h"
#include "ioctl_cmds.h"
#include "key_driver.h"
#include "iokey.h"
#include "irkey.h"
#include "adkey.h"
#include "slidekey.h"
#include "touch_key.h"
#include "rdec_key.h"
#endif

View File

@ -0,0 +1,85 @@
#ifndef IOCTL_INF_H
#define IOCTL_INF_H
#define IOCTL_SET_IRQ_NUM 1
#define IOCTL_SET_PRIORITY 2
#define IOCTL_SET_DATA_WIDTH 3
#define IOCTL_SET_SPEED 4
#define IOCTL_SET_DETECT_MODE 5
#define IOCTL_SET_DETECT_FUNC 6
#define IOCTL_SET_DETECT_TIME_INTERVAL 7
#define IOCTL_SET_PORT 8
#define IOCTL_SET_PORT_FUNC 9
#define IOCTL_SET_CS_PORT_FUNC 10
#define IOCTL_SET_READ_MODE 11
#define IOCTL_SET_WRITE_MODE 12
#define IOCTL_SET_WRITE_PROTECT 13
#define IOCTL_SET_START_BIT 14
#define IOCTL_SET_STOP_BIT 15
#define IOCTL_FLUSH 16
#define IOCTL_REGISTER_IRQ_HANDLER 17
#define IOCTL_UNREGISTER_IRQ_HANDLER 18
#define IOCTL_GET_SYS_TIME 19
#define IOCTL_SET_SYS_TIME 20
#define IOCTL_GET_ALARM 21
#define IOCTL_SET_ALARM 22
#define IOCTL_SET_CAP_LOWSPEED_CARD 23
#define IOCTL_SET_VDD50_EN 30
#define IOCTL_GET_WEEKDAY 32
#define IOCTL_CLR_READ_MODE 33
#define IOCTL_SET_READ_CRC 34
#define IOCTL_GET_READ_CRC 35
#define IOCTL_GET_VOLUME 36
#define IOCTL_SET_VOLUME 37
#define IOCTL_SET_ALARM_ENABLE 38
#define IOCTL_CMD_RESUME 39
#define IOCTL_CMD_SUSPEND 40
#define IOCTL_SET_BASE_ADDR 41
#define IOCTL_SET_ASYNC_MODE 42
#define IOCTL_GET_SPEED 43
#define IOCTL_SET_ACTIVE_STATUS 44
#define IOCTL_POWER_RESUME 45
#define IOCTL_POWER_SUSPEND 46
#define IOCTL_GET_ID 100
#define IOCTL_GET_SECTOR_SIZE 101
#define IOCTL_GET_BLOCK_SIZE 102
#define IOCTL_GET_CAPACITY 103
#define IOCTL_GET_WIDTH 104
#define IOCTL_GET_HEIGHT 105
#define IOCTL_GET_BLOCK_NUMBER 106
#define IOCTL_CHECK_WRITE_PROTECT 107
#define IOCTL_GET_STATUS 108
#define IOCTL_GET_TYPE 109
#define IOCTL_GET_MAX_LUN 110
#define IOCTL_GET_CUR_LUN 111
#define IOCTL_SET_CUR_LUN 112
#define IOCTL_SET_FORCE_RESET 113
#define IOCTL_SET_CAPACITY 114
#define IOCTL_ERASE_SECTOR 200
#define IOCTL_ERASE_BLOCK 201
#define IOCTL_ERASE_CHIP 202
#define IOCTL_SET_ENC_END 203
#define IOCTL_ERASE_PAGE 204
#define IOCTL_SDMMC_ERASE 205
#define IOCTL_SET_DATA_CALLBACK 301
#define IOCTL_GET_PART_INFO 320
struct ioctl_irq_handler {
void *priv;
void *handler;
};
#endif

View File

@ -0,0 +1,53 @@
#ifndef DEVICE_IOKEY_H
#define DEVICE_IOKEY_H
#include "typedef.h"
#include "device/device.h"
// enum key_connect_way {
// ONE_PORT_TO_LOW, //按键一个端口接低电平, 另一个端口接IO
// ONE_PORT_TO_HIGH, //按键一个端口接高电平, 另一个端口接IO
// DOUBLE_PORT_TO_IO, //按键两个端口接IO
// };
#define ONE_PORT_TO_LOW 0 //按键一个端口接低电平, 另一个端口接IO
#define ONE_PORT_TO_HIGH 1 //按键一个端口接高电平, 另一个端口接IO
#define DOUBLE_PORT_TO_IO 2 //按键两个端口接IO
#define CUST_DOUBLE_PORT_TO_IO 3
struct one_io_key {
u8 port;
};
struct two_io_key {
u8 in_port;
u8 out_port;
};
union key_type {
struct one_io_key one_io;
struct two_io_key two_io;
};
struct iokey_port {
union key_type key_type;
u8 connect_way;
u8 key_value;
};
struct iokey_platform_data {
u8 enable;
u8 num;
const struct iokey_port *port;
};
//IOKEY API:
extern int iokey_init(const struct iokey_platform_data *iokey_data);
extern u8 io_get_key_value(void);
#endif

View File

@ -0,0 +1,15 @@
#ifndef DEVICE_IRKEY_H
#define DEVICE_IRKEY_H
#include "typedef.h"
struct irkey_platform_data {
u8 enable;
u8 port;
};
extern u8 ir_get_key_value(void);
extern int irkey_init(const struct irkey_platform_data *irkey_data);
#endif

View File

@ -0,0 +1,70 @@
#ifndef SYS_KEY_DRIVER_H
#define SYS_KEY_DRIVER_H
#include "typedef.h"
typedef enum __KEY_DRIVER_TYPE {
KEY_DRIVER_TYPE_IO = 0x0,
KEY_DRIVER_TYPE_AD,
KEY_DRIVER_TYPE_RTCVDD_AD,
KEY_DRIVER_TYPE_IR,
KEY_DRIVER_TYPE_TOUCH,
KEY_DRIVER_TYPE_CTMU_TOUCH,
KEY_DRIVER_TYPE_RDEC,
KEY_DRIVER_TYPE_SLIDEKEY,
KEY_DRIVER_TYPE_SOFTKEY,
KEY_DRIVER_TYPE_BRIGHTNESS,
KEY_DRIVER_TYPE_VOICE,
KEY_DRIVER_TYPE_MAX,
} KEY_DRIVER_TYPE;
#define NO_KEY 0xff
#define KEY_NOT_SUPPORT 0x01
struct key_driver_para {
const u32 scan_time; //按键扫描频率, 单位ms
u8 last_key; //上一次get_value按键值
//== 用于消抖类参数
u8 filter_value; //用于按键消抖
u8 filter_cnt; //用于按键消抖时的累加值
const u8 filter_time; //当filter_cnt累加到base_cnt值时, 消抖有效
//== 用于判定长按和HOLD事件参数
const u8 long_time; //按键判定长按数量
const u8 hold_time; //按键判定HOLD数量
u8 press_cnt; //与long_time和hold_time对比, 判断long_event和hold_event
//== 用于判定连击事件参数
u8 click_cnt; //单击次数
u8 click_delay_cnt; //按键被抬起后等待连击事件延时计数
const u8 click_delay_time; ////按键被抬起后等待连击事件延时数量
u8 notify_value; //在延时的待发送按键值
u8 key_type;
u8(*get_value)(void);
};
//组合按键映射按键值
struct key_remap {
u8 bit_value;
u8 remap_value;
};
struct key_remap_data {
u8 remap_num;
const struct key_remap *table;
};
// key_driver API:
extern int key_driver_init(void);
#endif

View File

@ -0,0 +1,12 @@
#ifndef RDEC_KEY_H
#define RDEC_KEY_H
#include "typedef.h"
#include "asm/rdec.h"
int rdec_key_init(const struct rdec_platform_data *rdec_key_data);
s8 get_rdec_rdat(int i);
#endif

View File

@ -0,0 +1,31 @@
#ifndef DEVICE_SLIDEKEY_H
#define DEVICE_SLIDEKEY_H
#include "typedef.h"
#include "device/device.h"
#include "asm/adc_api.h"
struct slidekey_port {
u8 io;
u8 io_up_en; //是否用外部上拉1用外部上拉 0用内部上拉10K
u32 level;
u32 ad_channel;
int msg;
};
struct slidekey_platform_data {
u8 enable;
u8 num;
const struct slidekey_port *port;
};
//API:
extern int slidekey_init(const struct slidekey_platform_data *slidekey_data);
#endif

View File

@ -0,0 +1,18 @@
#ifndef DEVICE_TENT600_KEY_H
#define DEVICE_TENT600_KEY_H
#include "typedef.h"
#include "asm/adc_api.h"
struct tent600_key_platform_data {
u8 enalbe;
u8 tent600_key_pin;
u8 extern_up_en;
u32 ad_channel;
};
int tent600_key_init(const struct tent600_key_platform_data *tent600_key_data);
u8 tent600_get_key_value(void);
#endif

View File

@ -0,0 +1,16 @@
#ifndef DEVICE_TOUCH_KEY_H
#define DEVICE_TOUCH_KEY_H
#include "typedef.h"
#include "asm/plcnt.h"
/* =========== touch key API ============= */
//触摸按键初始化
int touch_key_init(const struct touch_key_platform_data *touch_key_data);
//获取触摸按键键值
u8 touch_key_get_value(void);
#endif

View File

@ -0,0 +1,60 @@
#ifndef _VM_H_
#define _VM_H_
#include "ioctl.h"
#include "device/device.h"
#define IOCTL_SET_VM_INFO _IOW('V', 1, 1)
#define IOCTL_GET_VM_INFO _IOW('V', 2, 1)
// enum {
// #<{(|
// * 用户自定义配置项 (0-64)
// |)}>#
// #<{(| ... |)}>#
// }
// VM define and api
typedef u16 vm_hdl;
struct vm_table {
u16 index;
u16 value_byte;
int value; //cache value which value_byte <= 4
};
typedef enum _vm_err {
VM_ERR_NONE = 0,
VM_INDEX_ERR = -0x100,
VM_INDEX_EXIST, //0xFF
VM_DATA_LEN_ERR, //0xFE
VM_READ_NO_INDEX, //0xFD
VM_READ_DATA_ERR, //0xFC
VM_WRITE_OVERFLOW, //0xFB
VM_NOT_INIT,
VM_INIT_ALREADY,
VM_DEFRAG_ERR,
VM_ERR_INIT,
VM_ERR_PROTECT
} VM_ERR;
// vm api
VM_ERR vm_eraser(void);
VM_ERR vm_init(void *dev_hdl, u32 vm_addr, u32 vm_len, u8 vm_mode);
//VM_ERR vm_db_create_table(const struct vm_table *table, int num);
void vm_check_all(u8 level); //level : default 0
u8 get_vm_statu(void);
// io api
//s32 vm_read(vm_hdl hdl, void *data_buf, u16 len);
//s32 vm_write(vm_hdl hdl, const void *data_buf, u16 len);
void spi_port_hd(u8 level);
bool sfc_erase_zone(u32 addr, u32 len);
void vm_api_write_mult(u16 start_id, u16 end_id, void *buf, u16 len, u32 delay);
int vm_api_read_mult(u16 start_id, u16 end_id, void *buf, u16 len);
#endif //_VM_H_

391
include_lib/system/event.h Normal file
View File

@ -0,0 +1,391 @@
#ifndef SYS_EVENT_H
#define SYS_EVENT_H
#include "generic/typedef.h"
#include "generic/list.h"
#include "generic/rect.h"
#define KEY_POWER_START 0
#define KEY_POWER 1
#define KEY_PREV 2
#define KEY_NEXT 3
#define KEY_OK 4
#define KEY_CANCLE 5
#define KEY_MENU 6
#define KEY_MODE 7
#define KEY_PHOTO 8
#define KEY_ENC 9
#define KEY_VOLUME_DEC 10
#define KEY_VOLUME_INC 11
#define KEY_PHONE 12
#define KEY_LEFT 37
#define KEY_UP 38
#define KEY_RIGHT 39
#define KEY_DOWN 40
#define KEY_0 48
#define KEY_1 49
#define KEY_2 50
#define KEY_3 51
#define KEY_4 52
#define KEY_5 53
#define KEY_6 54
#define KEY_7 55
#define KEY_8 56
#define KEY_9 57
#define KEY_F1 60
#define SYS_ALL_EVENT 0xffff
#define SYS_KEY_EVENT 0x0001
#define SYS_TOUCH_EVENT 0x0002
#define SYS_DEVICE_EVENT 0x0004
#define SYS_NET_EVENT 0x0008
#define SYS_BT_EVENT 0x0010
#define SYS_IR_EVENT 0x0020
#define SYS_PBG_EVENT 0x0040
#define SYS_BT_AI_EVENT 0x0080
#define SYS_AI_EVENT 0x0100
#define SYS_MATRIX_KEY_EVENT 0x0200
#define SYS_TOUCHPAD_EVENT 0x0400
#define SYS_ADT_EVENT 0x0800
#define SYS_AUD_EVENT 0x1000
#define DEVICE_EVENT_FROM_AT_UART (('A' << 24) | ('T' << 16) | ('U' << 8) | '\0')
#define DEVICE_EVENT_FROM_CHARGE (('C' << 24) | ('H' << 16) | ('G' << 8) | '\0')
#define DEVICE_EVENT_FROM_CFG_TOOL (('C' << 24) | ('F' << 16) | ('G' << 8) | '\0')
#define DEVICE_EVENT_FROM_POWER (('P' << 24) | ('O' << 16) | ('W' << 8) | '\0')
#define DEVICE_EVENT_FROM_CI_UART (('C' << 24) | ('I' << 16) | ('U' << 8) | '\0')
#define DEVICE_EVENT_FROM_CI_TWS (('C' << 24) | ('I' << 16) | ('T' << 8) | '\0')
#define DEVICE_EVENT_CHARGE_STORE (('S' << 24) | ('T' << 16) | ('O' << 8) | '\0')
#define DEVICE_EVENT_UMIDIGI_CHARGE_STORE (('Q' << 24) | ('C' << 16) | ('Y' << 8) | '\0')
#define DEVICE_EVENT_TEST_BOX (('T' << 24) | ('S' << 16) | ('B' << 8) | '\0')
#define DEVICE_EVENT_FROM_TONE (('T' << 24) | ('N' << 16) | ('E' << 8) | '\0')
#define DEVICE_EVENT_FROM_FM (('F' << 24) | ('M' << 16) | ('\0'<< 8) | '\0')
#define KEY_EVENT_FROM_TWS (('T' << 24) | ('W' << 16) | ('S' << 8) | '\0')
#define SYS_BT_EVENT_FROM_TWS (('T' << 24) | ('W' << 16) | ('S' << 8) | '\0')
#define DEVICE_EVENT_FROM_LINEIN (('A' << 24) | ('U' << 16) | ('X' << 8) | '\0')
#define DRIVER_EVENT_FROM_SD0 (('S' << 24) | ('D' << 16) | ('0' << 8) | '\0')
#define DRIVER_EVENT_FROM_SD1 (('S' << 24) | ('D' << 16) | ('1' << 8) | '\0')
#define DRIVER_EVENT_FROM_SD2 (('S' << 24) | ('D' << 16) | ('2' << 8) | '\0')
#define DEVICE_EVENT_FROM_MUSIC (('M' << 24) | ('S' << 16) | ('C' << 8) | '\0')
#define DEVICE_EVENT_FROM_USB_HOST (('U' << 24) | ('H' << 16) | '\0' | '\0')
#define DEVICE_EVENT_FROM_OTG (('O' << 24) | ('T' << 16) | ('G' << 8) | '\0')
#define DEVICE_EVENT_FROM_PC (('P' << 24) | ('C' << 16) | '\0' | '\0')
#define DEVICE_EVENT_FROM_UAC (('U' << 24) | ('A' << 16) | ('C' << 8) | '\0')
#define DEVICE_EVENT_FROM_ALM (('A' << 24) | ('L' << 16) | ('M' << 8) | '\0')
#define SYS_BT_EVENT_TYPE_CON_STATUS (('C' << 24) | ('O' << 16) | ('N' << 8) | '\0')
#define SYS_BT_EVENT_TYPE_HCI_STATUS (('H' << 24) | ('C' << 16) | ('I' << 8) | '\0')
#define SYS_BT_EVENT_BLE_STATUS (('B' << 24) | ('L' << 16) | ('E' << 8) | '\0')
#define SYS_BT_EVENT_FORM_COMMON (('C' << 24) | ('M' << 16) | ('M' << 8) | '\0')
#define DEVICE_EVENT_FROM_KEY (('K' << 24) | ('E' << 16) | ('Y' << 8) | '\0')
#define DEVICE_EVENT_FROM_CUSTOM (('C' << 24) | ('S' << 16) | ('T' << 8) | '\0')
#define SYS_BT_AI_EVENT_TYPE_STATUS (('B' << 24) | ('A' << 16) | ('I' << 8) | '\0')
#define DEVICE_EVENT_FROM_UART_RX_OVERFLOW (('U' << 24) | ('R' << 16) | ('F' << 8) | '\0')
#define DEVICE_EVENT_FROM_UART_RX_OUTTIME (('U' << 24) | ('R' << 16) | ('T' << 8) | '\0')
#define DEVICE_EVENT_FROM_DAC (('D' << 24) | ('A' << 16) | ('C' << 8) | '\0')
#define SYS_EVENT_FROM_CTRLER (('C' << 24) | ('T' << 16) | ('R' << 8) | '\0')
#define SYS_EVENT_FROM_RECORD (('R' << 24) | ('E' << 16) | ('C' << 8) | '\0')
#define DEVICE_EVENT_FROM_ENDLESS_LOOP_DEBUG (('E' << 24) | ('L' << 16) | ('D' << 8) | '\0')
#define DEVICE_EVENT_FROM_EARTCH (('E' << 24) | ('T' << 16) | ('H' << 8) | '\0')
#define DEVICE_EVENT_ONLINE_DATA (('O' << 24) | ('L' << 16) | ('D' << 8) | '\0')
#define SYS_BT_EVENT_FROM_KEY (('K' << 24) | ('E' << 16) | ('Y' << 8) | '\0')
#define SYS_BT_EVENT_FORM_SELF (('S' << 24) | ('E' << 16) | ('F' << 8) | '\0')
#define DEVICE_EVENT_FROM_ANC (('A' << 24) | ('N' << 16) | ('C' << 8) | '\0')
#define SYS_BT_EVENT_FORM_AT (('I' << 24) | ('A' << 16) | ('T' << 8) | '\0')
#define DEVICE_EVENT_FROM_ADAPTER (('A' << 24) | ('D' << 16) | ('A' << 8) | '\0')
#define DEVICE_EVENT_FROM_BOARD_UART (('B' << 24) | ('D' << 16) | ('U' << 8) | '\0')
#define AUDIO_EVENT_TRIM_IMU_START (('A' << 24) | ('T' << 16) | ('S' << 8) | '\0')
#define AUDIO_EVENT_TRIM_IMU_STOP (('A' << 24) | ('T' << 16) | ('E' << 8) | '\0')
enum {
KEY_EVENT_CLICK,
KEY_EVENT_LONG,
KEY_EVENT_HOLD,
KEY_EVENT_UP,
KEY_EVENT_DOUBLE_CLICK,
KEY_EVENT_TRIPLE_CLICK,
KEY_EVENT_FOURTH_CLICK,
KEY_EVENT_FIRTH_CLICK,
KEY_EVENT_USER,
KEY_EVENT_MAX,
};
enum {
DEVICE_EVENT_IN,
DEVICE_EVENT_OUT,
DEVICE_EVENT_ONLINE,
DEVICE_EVENT_OFFLINE,
DEVICE_EVENT_CHANGE,
};
enum {
TOUCH_EVENT_DOWN,
TOUCH_EVENT_MOVE,
TOUCH_EVENT_HOLD,
TOUCH_EVENT_UP,
TOUCH_EVENT_CLICK,
TOUCH_EVENT_DOUBLE_CLICK,
};
enum {
NET_EVENT_CMD,
NET_EVENT_DATA,
NET_EVENT_CONNECTED,
NET_EVENT_DISCONNECTED,
NET_EVENT_SMP_CFG_TIMEOUT,
};
struct key_event {
u8 init;
u8 type;
u16 event;
u32 value;
u32 tmr;
};
struct ir_event {
u8 event;
};
struct msg_event {
u8 event;
u8 value;
};
#if EVENT_TOUCH_ENABLE_CONFIG
struct touch_event {
u8 event;
struct position pos;
};
#endif
struct device_event {
u8 event;
int value;
};
struct chargestore_event {
u8 event;
u8 *packet;
u8 size;
};
struct testbox_event {
u8 event;
u8 *packet;
u8 size;
};
struct cfg_tool_event {
u8 event;
u8 *packet ;
u8 size;
};
struct umidigi_chargestore_event {
u8 event;
u8 value;
};
struct ancbox_event {
u8 event;
u32 value;
};
struct net_event {
u8 event;
u8 value;
};
struct bt_event {
u8 event;
u8 args[7];
u32 value;
};
struct axis_event {
u8 event;
s16 x;
s16 y;
};
struct codesw_event {
u8 event;
s8 value;
};
struct pbg_event {
u8 event;
u8 args[3];
};
struct adt_event {
u8 event;
u8 args[3];
};
struct uart_event {
void *ut_bus;
};
struct uart_cmd_event {
u8 type;
u8 cmd;
};
struct ai_event {
u32 value;
};
struct ear_event {
u8 value;
};
struct rcsp_event {
u8 event;
u8 args[6];
u8 size;
};
struct chargebox_event {
u8 event;
};
struct matrix_key_event {
u16 args[6]; //最多推6个按键出来如果需要推多个按键需要自行修改每个u16 低八位标识row 高八位标识col
u8 *map;
};
struct touchpad_event {
u8 gesture_event; //手势事件
s8 x;
s8 y;
};
struct sys_event {
u16 type;
u8 consumed;
void *arg;
union {
struct key_event key;
struct axis_event axis;
struct codesw_event codesw;
#if EVENT_TOUCH_ENABLE_CONFIG
struct touch_event touch;
#endif
struct device_event dev;
struct net_event net;
struct bt_event bt;
struct msg_event msg;
struct chargestore_event chargestore;
struct cfg_tool_event cfg_tool;
struct ir_event ir;
struct pbg_event pbg;
struct uart_event uart;
struct uart_cmd_event uart_cmd;
struct ai_event ai;
struct ear_event ear;
struct rcsp_event rcsp;
struct chargebox_event chargebox;
struct testbox_event testbox;
struct umidigi_chargestore_event umidigi_chargestore;
struct ancbox_event ancbox;
struct matrix_key_event matrix_key;
struct touchpad_event touchpad;
struct adt_event adt;
} u;
};
struct static_event_handler {
int event_type;
void (*handler)(struct sys_event *);
};
#define SYS_EVENT_HANDLER(type, fn, pri) \
const struct static_event_handler __event_handler_##fn sec(.sys_event.pri.handler) = { \
.event_type = type, \
.handler = fn, \
}
extern struct static_event_handler sys_event_handler_begin[];
extern struct static_event_handler sys_event_handler_end[];
#define list_for_each_static_event_handler(p) \
for (p = sys_event_handler_begin; p < sys_event_handler_end; p++)
int register_sys_event_handler(int event_type, int from, u8 priority,
void (*handler)(struct sys_event *));
void unregister_sys_event_handler(void (*handler)(struct sys_event *));
/*
* 事件通知函数,系统有事件发生时调用此函数
*/
void sys_event_notify(struct sys_event *e);
void sys_event_clear(struct sys_event *e);
void sys_key_event_disable();
void sys_key_event_enable();
void sys_key_event_filter_disable();
void sys_key_event_filter_enable();
void sys_touch_event_disable();
void sys_touch_event_enable();
/*
*下面四个为系统事件消耗函数,调用此函数后则对应的事件不在分发给其它任务
*
*/
void sys_event_consume(struct sys_event *e);
void sys_key_event_consume(struct key_event *e);
#if EVENT_TOUCH_ENABLE_CONFIG
void sys_touch_event_consume(struct touch_event *e);
#endif
void sys_device_event_consume(struct device_event *e);
/*
* 下面两个函数为按键和触摸事件接管函数,调用此函数后则对应的事件只发到当前任务
*
* on=true: 开始接管, on=false: 取消接管
*
* once: on = false 时有效,当前这次不接管, 事件可以继续发送到其它任务
*
*/
void sys_key_event_takeover(bool on, bool once);
void sys_touch_event_takeover(bool on, bool once);
int sys_key_event_map(struct key_event *org, struct key_event *new);
int sys_key_event_unmap(struct key_event *org, struct key_event *new);
#endif

1042
include_lib/system/fs/fs.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
#ifndef __FS_FILE_NAME_H__
#define __FS_FILE_NAME_H__
#include "generic/typedef.h"
#define D_LFN_MAX_SIZE 512
#define LFN_MAX_SIZE D_LFN_MAX_SIZE //不能超过512 //必须4byte对齐
typedef struct _LONG_FILE_NAME {
u16 lfn_cnt;
char lfn[LFN_MAX_SIZE]; //长文件名buffer
} LONG_FILE_NAME; //整理后的长文件名
typedef struct _FS_DIR_INFO {
u32 sclust; //dir sclust
u16 dir_type; // 0-folder,1-file
u16 fn_type; // 0-sfn,1-lfn
LONG_FILE_NAME lfn_buf; //long file name
} FS_DIR_INFO;
typedef struct _FS_DISP_INFO {
char tpath[128];
LONG_FILE_NAME file_name;
LONG_FILE_NAME dir_name;
u8 update_flag;
} FS_DISP_INFO;
typedef struct _FLASH_FAT_ADDRINFO {
u32 saddr; //当前连续簇块文件起始实际物理地址
u32 end_addr; //当前连续簇块结束位置
u32 file_len; //文件长度,如 JL.res文件的
} FLASH_FAT_ADDRINFO;
#endif /* __FS_FILE_NAME_H__ */

View File

@ -0,0 +1,222 @@
#ifndef _SDFILE_H_
#define _SDFILE_H_
#include "typedef.h"
//=======================================================//
// 默认宏配置定义 //
//=======================================================//
#ifndef SDFILE_STORAGE
#define SDFILE_STORAGE 0
#endif /* #ifndef SDFILE_STORAGE */
#define NOR_SDFILE_ENABLE 1
/********* sdfile 文件头 **********/
#define SDFILE_NAME_LEN 16
typedef struct sdfile_file_head {
u16 head_crc;
u16 data_crc;
u32 addr;
u32 len;
u8 attr;
u8 res;
u16 index;
char name[SDFILE_NAME_LEN];
} SDFILE_FILE_HEAD;
#if 0
////////////////////////////sdfile_file_head成员详细说明///////////////////////////////////////
typedef struct SDFILEJL_FILE_HEAD {
u16 u16Crc; // 结构体自身校验码
u16 u16DataCrc; // 文件数据校验码
u32 u32Address; // 数据存储地址
u32 u32Length; // 数据长度
u8 u8Attribute; // 属性
u8 u8Res; // 保留数据
u16 u16Index; // 文件编号从大到小排列编号为0时代表后面没有文件
char szFileName[16];// 文件名
} JL_SDFILE_HEAD;
////////////////////////////flash_head成员详细说明///////////////////////////////////////
typedef struct SDFILEJL_FLASH_HEAD_V2 {
u16 u16Crc; // 结构体自身校验码
u16 u16SizeForBurner; // 为烧写器保留的空间大小
char vid[4]; // 存放VID信息长度是4个byte
u32 u32FlashSize; // FLASH大小,由isd_download计算得出
u8 u8FsVersion; // flash类型BR18(0)/BR22(1)
u8 u8BlockAlingnModulus;// 对齐系数,对齐的值=对齐系数*256
u8 u8Res; // 保留
u8 u8SpecialOptFlag; // 用于标记是否需要生成2种flash格式的标记位目前只用1位
char pid[16]; // 存放PID信息长度是16个byte
} SDFILEJL_FLASH_HEAD_V2;
#endif
struct sdfile_dir {
u16 file_num;
struct sdfile_file_head head;
};
enum sdfile_err_table {
SDFILE_DIR_NOT_EXIST = -0xFF,
SDFILE_FILE_NOT_EXIST,
SDFILE_MALLOC_ERR,
SDFILE_VM_NOT_FIND,
SDFILE_DATA_CRC_ERR,
SDFILE_WRITE_AREA_NEED_ERASE_ERR,
SDFILE_SUSS = 0,
SDFILE_END,
};
#if (VFS_ENABLE == 1)
#if SDFILE_STORAGE
#define SDFILE_MAX_DEEPTH 2
struct sdfile_folder {
u32 saddr;
u32 addr;
u32 len;
};
struct sdfile_scn {
u8 subpath;
u8 cycle_mode;
u8 attr;
u8 deepth;
u16 dirCounter;
u16 fileCounter;
u16 fileNumber; // 当前文件序号
u16 totalFileNumber;
u16 last_file_number;
u16 fileTotalInDir; // 当前目录的根下有效文件的个数
u16 fileTotalOutDir; // 当前目录前的文件总数,目录循环模式下,需要用它来计算文件序号
u32 sclust_id;
const char *ftypes;
struct sdfile_file_head head;
struct sdfile_folder folder[SDFILE_MAX_DEEPTH];
};
#endif
typedef struct sdfile_file_t {
u32 fptr;
struct sdfile_file_head head;
#if SDFILE_STORAGE
struct sdfile_scn *pscn;
#endif
} SDFILE;
#else
typedef struct sdfile_file_t {
u32 fptr;
struct sdfile_file_head head;
} SDFILE, FILE;
struct vfs_attr {
u8 attr; //属性
u32 fsize; //文件大小
u32 sclust; //地址
};
SDFILE *sdfile_open(const char *path, const char *mode);
int sdfile_read(SDFILE *fp, void *buf, u32 len);
int sdfile_write(SDFILE *fp, void *buf, u32 len);
int sdfile_seek(SDFILE *fp, u32 offset, u32 fromwhere);
int sdfile_close(SDFILE *fp);
int sdfile_pos(SDFILE *fp);
int sdfile_len(SDFILE *fp);
int sdfile_get_name(SDFILE *fp, u8 *name, int len);
int sdfile_get_attrs(SDFILE *fp, struct vfs_attr *attr);
#if 0
#define fopen sdfile_open
#define fread sdfile_read
#define fseek sdfile_seek
#define fclose sdfile_close
#define fwrite sdfile_write
#define flen sdfile_len
#define fpos sdfile_pos
#define fget_name sdfile_get_name
#define fget_attrs sdfile_get_attrs
#else
static inline SDFILE *fopen(const char *path, const char *mode)
{
return sdfile_open(path, mode);
}
static inline int fread(SDFILE *fp, void *buf, u32 len)
{
return sdfile_read(fp, buf, len);
}
static inline int fwrite(SDFILE *fp, void *buf, u32 len)
{
return sdfile_write(fp, buf, len);
}
static inline int fseek(SDFILE *fp, u32 offset, u32 fromwhere)
{
return sdfile_seek(fp, offset, fromwhere);
}
static inline int fclose(SDFILE *fp)
{
return sdfile_close(fp);
}
static inline int fpos(SDFILE *fp)
{
return sdfile_pos(fp);
}
static inline int flen(SDFILE *fp)
{
return sdfile_len(fp);
}
static inline int fget_name(SDFILE *fp, u8 *name, int len)
{
return sdfile_get_name(fp, name, len);
}
static inline int fget_attrs(SDFILE *fp, struct vfs_attr *attr)
{
return sdfile_get_attrs(fp, attr);
}
#endif
#endif /* VFS_ENABLE */
int sdfile_delete_data(SDFILE *fp);
#define fdel_data sdfile_delete_data
#ifndef SDFILE_MOUNT_PATH
#define SDFILE_MOUNT_PATH "mnt/sdfile"
#endif /* #ifndef SDFILE_MOUNT_PATH */
#if (USE_SDFILE_NEW)
#ifndef SDFILE_APP_ROOT_PATH
#define SDFILE_APP_ROOT_PATH SDFILE_MOUNT_PATH"/app/" //app分区
#endif /* #ifndef SDFILE_APP_ROOT_PATH */
#ifndef SDFILE_RES_ROOT_PATH
#define SDFILE_RES_ROOT_PATH SDFILE_MOUNT_PATH"/res/" //资源文件分区
#endif /* #ifndef SDFILE_RES_ROOT_PATH */
#else
#ifndef SDFILE_RES_ROOT_PATH
#define SDFILE_RES_ROOT_PATH SDFILE_MOUNT_PATH"/C/"
#endif /* #ifndef SDFILE_RES_ROOT_PATH */
#endif /* #if (USE_SDFILE_NEW) */
//获取flash物理大小, 单位: Byte
u32 sdfile_get_disk_capacity(void);
//flash addr -> cpu addr
u32 sdfile_flash_addr2cpu_addr(u32 offset);
//cpu addr -> flash addr
u32 sdfile_cpu_addr2flash_addr(u32 offset);
void sdfile_head_addr_get(char *name, u32 *addr, u32 *len);
u32 init_norsdfile_hdl(void);
int set_res_startaddr(int offset);
#endif /* _SDFILE_H_ */

View File

@ -0,0 +1,161 @@
#ifndef VIRTUAL_DISK_H
#define VIRTUAL_DISK_H
#include "system/includes.h"
#define VIR_FILE_TYPE_MP3 1
#define VIR_FILE_TYPE_WAV 2
extern const struct device_operations virfat_flash_dev_ops;
extern const struct device_operations private_sfc_dev_ops;
typedef enum {
FS_FAT12 = 0x01,
FS_FAT16 = 0x02,
FS_FAT32 = 0x04,
FS_EXFAT = 0x14,
} FS_TYPE;
#define JLFAT_DIRINFO_ENABLE 0
#if JLFAT_DIRINFO_ENABLE
typedef struct jlfat_dirinfo {
u8 name[12]; //文件名字
int fsize; // 文件大小
u16 fix_date; //修改日期
u16 fix_time; //修改时间
u8 attr; //文件属性
int sclust; //文件起始簇
} JLFAT_DIRINFO;
#endif
typedef struct _virfat_flash_t {
u32 fatbase;
// u32 fatbase2;
u16 fatsize;
u32 dirbase;
u32 database;
u32 clustSize;
u32 max_clust;
u32 capacity;
u8 csize;
FS_TYPE fs_type;
char re_devname[24];
u32 flash_fatfs_addr;
u32 fatfs_len;
} virfat_flash_t;
typedef struct _dir_entry {
u8 name[12];
u32 fileSize;
} dir_entry_t;
#if 0
extern void virfat_flash_rand_file_size();
extern void virtual_disk_reduce_file_size(tu8 file_num);
extern void virtual_disk_remove_files(tu8 file_type);
extern void virtual_disk_reduce_file_size(tu8 file_num);
extern u8 virfat_flash_init(void *buf_512, void (*fun_read_file)(u32, u32, u8 *, u32));
#endif
#define MIN_FAT16 4086 /* Minimum number of clusters for FAT16 */
#define MIN_FAT32 65526 /* Minimum number of clusters for FAT32 */
#define AM_RDO 0x01 /* Read only */
#define AM_HID 0x02 /* Hidden */
#define AM_SYS 0x04 /* System */
#define AM_VOL 0x08 /* Volume label */
#define AM_LFN 0x0F /* LFN entry */
#define AM_DIR 0x10 /* Directory */
#define AM_ARC 0x20 /* Archive */
#define AM_FCH 0x80 /* exFAT下,文件簇连续标志 */
#define AM_FRG 0x40 /* exFAT下,文件簇BITMAP 有碎片 */
#define AM_LFN0_START 0x1
#define AM_LFN0_LEN 10
#define AM_LFN1_START 0xE
#define AM_LFN1_LEN 12
#define AM_LFN2_START 0x1C
#define AM_LFN2_LEN 4
#define AM_LFN_LEN 26
#define AM_EX_DIR_STRETCHED 0x08
#define BS_jmpBoot 0
#define BS_OEMName 3
#define BPB_BytsPerSec_l 11
#define BPB_BytsPerSec_h 12
#define BPB_SecPerClus 13
#define BPB_RsvdSecCnt 14
#define BPB_NumFATs 16
#define BPB_RootEntCnt 17
#define BPB_TotSec16 19
#define BPB_Media 21
#define BPB_FATSz16 22
#define BPB_SecPerTrk 24
#define BPB_NumHeads 26
#define BPB_HiddSec 28
#define BPB_TotSec32 32
#define BS_55AA 510
#define BS_DrvNum 36
#define BS_BootSig 38
#define BS_VolID 39
#define BS_VolLab 43
#define BS_FilSysType 54
#define BPB_FATSz32 36
#define BPB_ExtFlags 40
#define BPB_FSVer 42
#define BPB_RootClus 44
#define BPB_FSInfo 48
#define BPB_BkBootSec 50
#define BS_DrvNum32 64
#define BS_BootSig32 66
#define BS_VolID32 67
#define BS_VolLab32 71
#define BS_FilSysType32 82
#define BS_FileSysTypeexFAT 5
#define BPB_FatOffset 80
#define BPB_FatLength 84
#define BPB_ClusterHeapOffset 88
#define BPB_ClusterCount 92
#define BPB_FirstClusterOfRootDirectory 96
#define BPB_VolumeFlags 106
#define BPB_BytesPerSectorShift 108
#define BPB_SectorsPerClusterShift 109
#define BPB_NumberOfFats 110
#define MBR_Table 446
#define FSI_LeadSig 0 /* FSI: Leading signature (4) */
#define FSI_StrucSig 484 /* FSI: Structure signature (4) */
#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */
#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */
///for FAT12/FAT16/FAT32
#define DIR_Name 0 /* Short file name (11) */
#define DIR_Attr 11 /* Attribute (1) */
#define DIR_NTres 12 /* NT flag (1) */
#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */
#define DIR_CrtTime 14 /* Created time (2) */
#define DIR_CrtDate 16 /* Created date (2) */
#define DIR_LstAccDate 18 /* Last accessed date (2) */
#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */
#define DIR_WrtTime 22 /* Modified time (2) */
#define DIR_WrtDate 24 /* Modified date (2) */
#define DIR_FstClusLO 26
#define DIR_FileSize 28
#define LDIR_Attr 11 /* LFN attribute (1) */
#define LDIR_Type 12 /* LFN type (1) */
#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */
////for exFAT
#define DIR_FileChainFlags 1
#define DIR_NameLen 3
#define DIR_AttrexFAT 4
#define DIR_FileSizeexFAT 8
#define DIR_FstClustexFAT 20
#define DIR_FileSize2exFAT 24
#endif

View File

@ -0,0 +1,44 @@
#ifndef ASCII_LIB_H
#define ASCII_LIB_H
#ifdef __cplusplus
extern "C" {
#endif
#include "typedef.h"
void ASCII_ToLower(void *buf, u32 len);
void ASCII_ToUpper(void *buf, u32 len);
u32 ASCII_StrCmp(const char *src, const char *dst, u32 len);
int ASCII_StrCmpNoCase(const char *src, const char *dst, int len);
void ASCII_IntToStr(void *pStr, u32 intNum, u32 strLen, u32 bufLen);
u32 ASCII_StrToInt(const void *pStr, u32 *pRint, u32 strLen);
u32 ASCII_StrLen(void *str, u32 len);
u32 ASCII_WStrLen(void *str, u32 len);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,81 @@
#ifndef ATOMIC_H
#define ATOMIC_H
#include "cpu.h"
#include "irq.h"
typedef struct {
int counter;
} atomic_t;
static inline int atomic_add_return(int i, atomic_t *v)
{
int val;
CPU_SR_ALLOC();
CPU_CRITICAL_ENTER();
val = v->counter;
v->counter = val += i;
CPU_CRITICAL_EXIT();
return val;
}
static inline int atomic_sub_return(int i, atomic_t *v)
{
int val;
CPU_SR_ALLOC();
CPU_CRITICAL_ENTER();
val = v->counter;
v->counter = val -= i;
CPU_CRITICAL_EXIT();
return val;
}
static inline int atomic_set(atomic_t *v, int i)
{
int val = 0;
CPU_SR_ALLOC();
CPU_CRITICAL_ENTER();
v->counter = i;
CPU_CRITICAL_EXIT();
return val;
}
#define DEFINE_ATOMIC(x) \
atomic_t x = {.counter = 0}
#define atomic_add(i, v) atomic_add_return(i, v)
#define atomic_sub(i, v) atomic_sub_return(i, v)
#define atomic_read(v) arch_atomic_read(v)
/*#define atomic_set(v,i) (((v)->counter) = (i))*/
#define atomic_inc(v) atomic_add(1, v)
#define atomic_dec(v) atomic_sub(1, v)
#define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
#define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
#define atomic_inc_return(v) (atomic_add_return(1, v))
#define atomic_dec_return(v) (atomic_sub_return(1, v))
#define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
#define atomic_add_negative(i,v) (atomic_add_return(i, v) < 0)
#endif

View File

@ -0,0 +1,302 @@
#ifndef CIRCULAR_BUF_INTERFACE_H
#define CIRCULAR_BUF_INTERFACE_H
#include "typedef.h"
#include "system/spinlock.h"
#ifndef CONFIG_CBUF_IN_MASKROM
/* --------------------------------------------------------------------------*/
/**
* @brief cbuffer结构体
*/
/* ----------------------------------------------------------------------------*/
typedef struct _cbuffer {
u8 *begin;
u8 *end;
u8 *read_ptr;
u8 *write_ptr;
u8 *tmp_ptr ;
u32 tmp_len;
u32 data_len;
u32 total_len;
spinlock_t lock;
} cbuffer_t;
#else /* #ifndef CONFIG_CBUF_IN_MASKROM */
/* ---------------------------------------------------------------------------- */
/**
* @brief cbuffer结构体
* @note: 以下结构体成员不可修改
*/
/* ---------------------------------------------------------------------------- */
typedef struct _cbuffer {
u8 *begin;
u8 *end;
u8 *read_ptr;
u8 *write_ptr;
u8 *tmp_ptr ;
u32 tmp_len;
u32 data_len;
u32 total_len;
spinlock_t lock;
} cbuffer_t;
#endif /* #ifndef CONFIG_CBUF_IN_MASKROM */
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:全局
* @brief cbuffer初始化
*
* @param [in] cbuffer cbuffer 句柄
* @param [in] buf 缓存空间
* @param [in] size 缓存总大小
*/
/* ----------------------------------------------------------------------------*/
void cbuf_init(cbuffer_t *cbuffer, void *buf, u32 size);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:cb_memcpy管理
* @brief 把cbuffer_t结构体管理的内存空间的数据拷贝到buf数组
* @param [in] cbuffer cbuffer 句柄
* @param [out] buf 指向用于存储读取内容的目标数组
* @param [in] len 要读取的字节长度
*
* @return 成功读取的字节长度
*/
/* ----------------------------------------------------------------------------*/
u32 cbuf_read(cbuffer_t *cbuffer, void *buf, u32 len);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:cb_memcpy管理
* @brief 把buf数组数据拷贝cbuffer_t结构体管理的内存空间
*
* @param [in] cbuffer cbuffer 句柄
* @param [in] buf 指向用于存储写入内容的目标数组
* @param [in] len 要写入的字节长度
*
* @return 成功写入的字节长度
*/
/* ----------------------------------------------------------------------------*/
u32 cbuf_write(cbuffer_t *cbuffer, void *buf, u32 len);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:全局
* @brief 判断是否可写入len字节长度的数据
*
* @param [in] cbuffer cbuffer 句柄
* @param [in] len len字节长度的数据
*
* @return 返回可以写入的len字节长度
*/
/* ----------------------------------------------------------------------------*/
u32 cbuf_is_write_able(cbuffer_t *cbuffer, u32 len);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:外部内存管理
* @brief 预分配待写入数据的空间要和cbuf_write_updata()配套使用,更新cbuf管理handle数据。
*
* @param [in] cbuffer cbuffer句柄
* @param [in] len 回传可以最多写入len字节长度的数据
*
* @return 当前写指针的地址
*/
/* ----------------------------------------------------------------------------*/
void *cbuf_write_alloc(cbuffer_t *cbuffer, u32 *len);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:外部内存管理
* @brief 更新cbuf管理handle的写指针位置和数据长度
*
* @param [in] cbuffer cbuffer句柄
* @param [in] len 在非cbuffer_t结构体包含的内存空间中写入的数据的实际字节长度
*
* @return 当前写指针的地址
*/
/* ----------------------------------------------------------------------------*/
void cbuf_write_updata(cbuffer_t *cbuffer, u32 len);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:外部内存管理
* @brief 预分配待读取数据的空间,需要和cbuf_read_updata()配套使用,更新cbuf管理handle数据
*
* @param [in] cbuffer cbuffer 句柄
* @param [in] len 回传可以最多读取len字节长度的数据
*
* @return 当前读指针的地址
*/
/* ----------------------------------------------------------------------------*/
void *cbuf_read_alloc(cbuffer_t *cbuffer, u32 *len);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:外部内存管理
* @brief 更新cbuf管理handle的读指针位置和数据长度
*
* @param [in] cbuffer cbuffer 句柄
* @param [in] len 在非cbuffer_t结构体包含的内存空间中读取的数据的实际字节长度
*/
/* ----------------------------------------------------------------------------*/
void cbuf_read_updata(cbuffer_t *cbuffer, u32 len);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:外部内存管理
* @brief 清空cbuffer空间
*
* @param [in] cbuffer cbuffer 句柄
*/
/* ----------------------------------------------------------------------------*/
void cbuf_clear(cbuffer_t *cbuffer);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:cb_memcpy管理。
* @brief 指定位置进行数据重写
*
* @param [in] cbuffer cbuffer 句柄
* @param [in] begin 指向需要重写内容的开始地址
* @param [out] buf 指向用于存储重写内容的目标数组
* @param [in] len 待重写内容的长度
*
* @return 成功重写的字节长度
*/
/* ----------------------------------------------------------------------------*/
u32 cbuf_rewrite(cbuffer_t *cbuffer, void *begin, void *buf, u32 len);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:cb_memcpy管理
* @brief 更新指向上一次操作的指针为当前指针,并刷新数据长度
*
* @param [in] cbuffer cbuffer 句柄
*/
/* ----------------------------------------------------------------------------*/
void cbuf_discard_prewrite(cbuffer_t *cbuffer);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:cb_memcpy管理
* @brief 操作指针回退到上一次的操作位置,并刷新数据长度
*
* @param [in] cbuffer cbuffer 句柄
*/
/* ----------------------------------------------------------------------------*/
void cbuf_updata_prewrite(cbuffer_t *cbuffer);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:cb_memcpy管理
* @brief 回退写入内容,从上一次的操作的指针处进行覆盖填充
*
* @param [in] cbuffer cbuffer 句柄
* @param [out] buf 指向用于覆盖写入内容的目标数组
* @param [in] len 填充数据的字节长度
*
* @return 成功填充数据的字节长度
*/
/* ----------------------------------------------------------------------------*/
u32 cbuf_prewrite(cbuffer_t *cbuffer, void *buf, u32 len);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:全局
* @brief 获取指向写指针的地址
*
* @param [in] cbuffer cbuffer 句柄
*
* @return 写指针的地址
*/
/* ----------------------------------------------------------------------------*/
void *cbuf_get_writeptr(cbuffer_t *cbuffer);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:全局
* @brief 获取cbuffer存储的数据的字节长度
*
* @param [in] cbuffer cbuffer句柄
*
* @return 获取cbuffer存储的数据的字节长度
*/
/* ----------------------------------------------------------------------------*/
u32 cbuf_get_data_size(cbuffer_t *cbuffer);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:全局
* @brief 获取指向读指针的地址
*
* @param [in] cbuffer cbuffer句柄
*
* @return 读指针的地址
*/
/* ----------------------------------------------------------------------------*/
void *cbuf_get_readptr(cbuffer_t *cbuffer);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:全局
* @brief 读指针向后回退
*
* @param [in] cbuffer cbuffer 句柄
* @param [in] len 要回退的字节长度
*
* @return 成功回退的字节长度
*/
/* ----------------------------------------------------------------------------*/
u32 cbuf_read_goback(cbuffer_t *cbuffer, u32 len);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:全局
* @brief 获取存储数据的字节长度
*
* @param [in] cbuffer cbuffer 句柄
*
* @return 存储数据的字节长度
*/
/* ----------------------------------------------------------------------------*/
u32 cbuf_get_data_len(cbuffer_t *cbuffer);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:memcpy管理+cbuf_read_alloc系列管理函数
* @brief 预分配待读取数据的空间,并把读取到的数据存入buf数组
*
* @param [in] cbuffer cbuffer 句柄
* @param [out] buf 存储读取的数据的目标buf数组
* @param [in] len 要读取的数据的字节长度
*
* @return
*/
/* ----------------------------------------------------------------------------*/
u32 cbuf_read_alloc_len(cbuffer_t *cbuffer, void *buf, u32 len);
/* --------------------------------------------------------------------------*/
/**
* @brief 适用范围:memcpy管理+cbuf_read_alloc系列管理函数
* @brief 更新cbuf管理handle的读指针位置和数据长度
*
* @param [in] cbuffer cbuffer 句柄
* @param [in] len 要更新的数据的字节长度
*/
/* ----------------------------------------------------------------------------*/
void cbuf_read_alloc_len_updata(cbuffer_t *cbuffer, u32 len);
#endif

View File

@ -0,0 +1,22 @@
#ifndef GENERIC_CPU_H
#define GENERIC_CPU_H
#include <asm/cpu.h>
#endif

View File

@ -0,0 +1,10 @@
#ifndef _LITE_DEBUG_H_
#define _LITE_DEBUG_H_
extern void puts_lite(const char *out);
extern void put_buf_lite(void *_buf, u32 len);
extern int printf_lite(const char *format, ...);
#endif /* #ifdef _LITE_DEBUG_H_ */

View File

@ -0,0 +1,40 @@
#ifndef _ASM_GENERIC_ERRNO_BASE_H
#define _ASM_GENERIC_ERRNO_BASE_H
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Argument list too long */
#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file number */
#define ECHILD 10 /* No child processes */
#define EAGAIN 11 /* Try again */
#define ENOMEM 12 /* Out of memory */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
#define ENOTBLK 15 /* Block device required */
#define EBUSY 16 /* Device or resource busy */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */
#define ENODEV 19 /* No such device */
#define ENOTDIR 20 /* Not a directory */
#define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */
#define ENFILE 23 /* File table overflow */
#define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Not a typewriter */
#define ETXTBSY 26 /* Text file busy */
#define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Illegal seek */
#define EROFS 30 /* Read-only file system */
#define EMLINK 31 /* Too many links */
#define EPIPE 32 /* Broken pipe */
#define EDOM 33 /* Math argument out of domain of func */
#define ERANGE 34 /* Math result not representable */
#define ETIMEDOUT 35 /* Connection timed out */
#endif

View File

@ -0,0 +1,44 @@
#ifndef ASM_GPIO_H
#define ASM_GPIO_H
#include "asm/gpio.h"
#define GPIO2PORT(gpio) (gpio / IO_GROUP_NUM)
void gpio_port_lock(unsigned int port);
void gpio_port_unlock(unsigned int port);
int __gpio_direction_input(unsigned int gpio);
int gpio_direction_input(unsigned int gpio);
int __gpio_direction_output(unsigned int gpio, int value);
int gpio_direction_output(unsigned int gpio, int value);
int __gpio_set_pull_up(unsigned int gpio, int value);
int gpio_set_pull_up(unsigned int gpio, int value);
int __gpio_set_pull_down(unsigned int gpio, int value);
int gpio_set_pull_down(unsigned int gpio, int value);
int __gpio_set_hd(unsigned int gpio, int value);
int gpio_set_hd(unsigned int gpio, int value);
int __gpio_set_die(unsigned int gpio, int value);
int gpio_set_die(unsigned int gpio, int value);
int __gpio_set_output_clk(unsigned int gpio, int clk);
int gpio_set_output_clk(unsigned int gpio, int clk);
int __gpio_read(unsigned int gpio);
int gpio_read(unsigned int gpio);
#endif

View File

@ -0,0 +1,36 @@
#ifndef GENERIC_INCLUDES_H
#define GENERIC_INCLUDES_H
#include "errno-base.h"
#include "typedef.h"
#include "ascii.h"
#include "atomic.h"
#include "ioctl.h"
#include "cpu.h"
#include "gpio.h"
#include "irq.h"
#include "jiffies.h"
#include "list.h"
#include "printf.h"
#include "rect.h"
#include "version.h"
#include "lbuf.h"
#include "lbuf_lite.h"
#include "circular_buf.h"
#include "index.h"
#include "debug_lite.h"
#endif

View File

@ -0,0 +1,22 @@
#ifndef INDEX_H
#define INDEX_H
#include "typedef.h"
#define TABLE(t) t, ARRAY_SIZE(t)
int index_of_table8(u8 value, const u8 *table, int table_size);
int index_of_table16(u16 value, const u16 *table, int table_size);
int index_of_table32(u32 value, const u32 *table, int table_size);
#endif

View File

@ -0,0 +1,106 @@
#ifndef _ASM_GENERIC_IOCTL_H
#define _ASM_GENERIC_IOCTL_H
/* ioctl command encoding: 32 bits total, command in lower 16 bits,
* size of the parameter structure in the lower 14 bits of the
* upper 16 bits.
* Encoding the size of the parameter structure in the ioctl request
* is useful for catching programs compiled with old versions
* and to avoid overwriting user space outside the user buffer area.
* The highest 2 bits are reserved for indicating the ``access mode''.
* NOTE: This limits the max parameter size to 16kB -1 !
*/
/*
* The following is for compatibility across the various Linux
* platforms. The generic ioctl numbering scheme doesn't really enforce
* a type field. De facto, however, the top 8 bits of the lower 16
* bits are indeed used as a type field, so we might just as well make
* this explicit here. Please be sure to use the decoding macros
* below from now on.
*/
#define _IOC_NRBITS 8
#define _IOC_TYPEBITS 8
/*
* Let any architecture override either of the following before
* including this file.
*/
#ifndef _IOC_SIZEBITS
# define _IOC_SIZEBITS 14
#endif
#ifndef _IOC_DIRBITS
# define _IOC_DIRBITS 2
#endif
#define _IOC_NRMASK ((1 << _IOC_NRBITS)-1)
#define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1)
#define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1)
#define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1)
#define _IOC_NRSHIFT 0
#define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS)
#define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS)
#define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS)
/*
* Direction bits, which any architecture can choose to override
* before including this file.
*/
#ifndef _IOC_NONE
# define _IOC_NONE 0U
#endif
#ifndef _IOC_WRITE
# define _IOC_WRITE 1U
#endif
#ifndef _IOC_READ
# define _IOC_READ 2U
#endif
#define _IOC(dir,type,nr,size) \
(((dir) << _IOC_DIRSHIFT) | \
((type) << _IOC_TYPESHIFT) | \
((nr) << _IOC_NRSHIFT) | \
((size) << _IOC_SIZESHIFT))
#ifdef __KERNEL__
/* provoke compile error for invalid uses of size argument */
extern unsigned int __invalid_size_argument_for_IOC;
#define _IOC_TYPECHECK(t) \
((sizeof(t) == sizeof(t[1]) && \
sizeof(t) < (1 << _IOC_SIZEBITS)) ? \
sizeof(t) : __invalid_size_argument_for_IOC)
#else
#define _IOC_TYPECHECK(t) (sizeof(t))
#endif
/* used to create numbers */
#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
#define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
#define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
#define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
/* used to decode ioctl numbers.. */
#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)
#define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK)
#define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK)
#define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK)
/* ...and for the drivers/sound files... */
#define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT)
#define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT)
#define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT)
#define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT)
#define IOCSIZE_SHIFT (_IOC_SIZESHIFT)
#endif /* _ASM_GENERIC_IOCTL_H */

View File

@ -0,0 +1,23 @@
#ifndef __IRQ_H_
#define __IRQ_H_
#include "asm/irq.h"
#endif

View File

@ -0,0 +1,35 @@
#ifndef JIFFIES_H
#define JIFFIES_H
/* timer interface */
/* Parameters used to convert the timespec values: */
#define HZ 100L
#define MSEC_PER_SEC 1000L
#define USEC_PER_MSEC 1000L
#define NSEC_PER_USEC 1000L
#define NSEC_PER_MSEC 1000000L
#define USEC_PER_SEC 1000000L
#define NSEC_PER_SEC 1000000000L
#define FSEC_PER_SEC 1000000000000000LL
#ifndef __ASSEMBLY__
extern volatile unsigned long jiffies;
extern unsigned long jiffies_msec();
extern unsigned long jiffies_half_msec();
#endif
#define JIFFIES_CIRCLE 0x7FFFFFF
#define time_after(a,b) ((long)(b) - (long)(a) < 0)
#define time_before(a,b) time_after(b,a)
extern unsigned char jiffies_unit;
#define msecs_to_jiffies(msec) ((msec)/jiffies_unit)
#define jiffies_to_msecs(j) ((j)*jiffies_unit)
#endif

View File

@ -0,0 +1,262 @@
#ifndef LBUF_H
#define LBUF_H
#include "typedef.h"
#include "list.h"
#include "system/spinlock.h"
#ifndef CONFIG_LBUF_IN_MASKROM
#define LBUF_DEBUG 0
struct lbuff_head {
#if LBUF_DEBUG
int magic_a; /*!< 测试验证变量*/
#endif
struct list_head head; /*!< 指向hentry链表*/
struct list_head free; /*!< 指向hfree链表*/
spinlock_t lock; /*!< 混合自旋锁,单核是为开关临界区,多核是自旋锁.*/
u8 align; /*!< 数据包字节对齐*/
u16 priv_len; /*!< 数据包结构体的最小长度*/
u32 total_size; /*!< 总大小*/
u32 last_addr; /*!< 指向free链表中找到的足够长度的hfree结构体地址*/
void *priv;
#if LBUF_DEBUG
int magic_b; /*!< 测试验证变量*/
#endif
};
struct lbuff_state {
u32 avaliable; /*!< 剩余空间的字节长度*/
u32 fragment; /*!< lbuf内存碎片块数量*/
u32 max_continue_len; /*!< 最大的剩余内存块的字节长度*/
int num; /*!< 剩余内存块数量*/
};
#else /* #ifndef CONFIG_LBUF_IN_MASKROM */
/* ---------------------------------------------------------------------------- */
/**
* @brief:
* @note: 以下结构体成员不可修改
*/
/* ---------------------------------------------------------------------------- */
struct lbuff_head {
#if 0 //LBUF_DEBUG
int magic_a; /*!< 测试验证变量*/
#endif
struct list_head head; /*!< 指向hentry链表*/
struct list_head free; /*!< 指向hfree链表*/
spinlock_t lock; /*!< 混合自旋锁,单核是为开关临界区,多核是自旋锁.*/
u8 align; /*!< 数据包字节对齐*/
u16 priv_len; /*!< 数据包结构体的最小长度*/
u32 total_size; /*!< 总大小*/
u32 last_addr; /*!< 指向free链表中找到的足够长度的hfree结构体地址*/
void *priv;
#if 0 //LBUF_DEBUG
int magic_b; /*!< 测试验证变量*/
#endif
};
struct lbuff_state {
u32 avaliable; /*!< 剩余空间的字节长度*/
u32 fragment; /*!< lbuf内存碎片块数量*/
u32 max_continue_len; /*!< 最大的剩余内存块的字节长度*/
int num; /*!< 剩余内存块数量*/
};
#endif /* #ifndef CONFIG_LBUF_IN_MASKROM */
/* --------------------------------------------------------------------------*/
/**
* @brief 链表buf初始化
*
* @param [in] buf 需要lbuf进行管理的内存
* @param [in] len 内存长度
* @param [in] align 输入对管理的内存进行对齐的参数,避免后续使用因地址不对齐产生碎片
* @param [in] priv_head_len 要管理的一个数据包结构体的最小的长度
*
* @return lbuf操作句柄
*/
/* --------------------------------------------------------------------------*/
struct lbuff_head *lbuf_init(void *buf, u32 len, int align, int priv_head_len);
/* --------------------------------------------------------------------------*/
/**
* @brief 分配内存空间进行存储数据包
*
* @param [in] head lbuf操作句柄
* @param [in] len 需要存入的数据包的长度
*
* @return 成功则返回进行存储数据包的地址,调用时候需要用户把该块内存的类型初始化为数据包结构体的类型。失败则返回NULL。
*/
/* --------------------------------------------------------------------------*/
void *lbuf_alloc(struct lbuff_head *head, u32 len);
/* --------------------------------------------------------------------------*/
/**
* @brief 重新分配lbuf_alloc()返回用于存储数据包的lbuf空间
*
* @param [in] lbuf lbuf_alloc()返回用于存储数据包的地址
* @param [in] size 需重新分配的空间的字节长度.注:size的大小只能比lbuf_alloc()中的len小,即只能重新分配更小的lbuf空间,不能扩大空间.
*
* @return 重新分配后用于存储数据包的地址。失败则返回空指针。注:重新分配最好使用lbuf_real_size()获取lbuf空间的长度确认是否分配成功
*/
/* --------------------------------------------------------------------------*/
void *lbuf_realloc(void *lbuf, int size);
/* --------------------------------------------------------------------------*/
/**
* @brief 判断lbuf空间内的内容是否为空
*
* @param [in] head lbuf操作句柄
*
* @return 返回1则为空,0则不为空
*/
/* --------------------------------------------------------------------------*/
int lbuf_empty(struct lbuff_head *head);
/* --------------------------------------------------------------------------*/
/**
* @brief 清空lbuf空间内进行已经分配给数据包的空间
*
* @param [in] head lbuf操作句柄
*/
/* --------------------------------------------------------------------------*/
void lbuf_clear(struct lbuff_head *head);
/* --------------------------------------------------------------------------*/
/**
* @brief 把数据包写入分配好的lbuf区域
*
* @param [in] lbuf lbuf_alloc()返回用于存储数据包的地址
* @param [in] channel_map 选择映射到哪个通道,最多8个通道,使用位映射的方式进行通道对应.
*/
/* --------------------------------------------------------------------------*/
void lbuf_push(void *lbuf, u8 channel_map);
/* --------------------------------------------------------------------------*/
/**
* @brief 读取对应的通道映射的lbuf区域存储的内容
*
* @param [in] head lbuf操作句柄
* @param [in] channel 需要读取的通道值,一般使用BIT(n),n为需要读取的通道
*
* @return 成功则返回存储对应的通道映射的数据包的地址
*/
/* --------------------------------------------------------------------------*/
void *lbuf_pop(struct lbuff_head *head, u8 channel);
/* --------------------------------------------------------------------------*/
/**
* @brief 释放存储数据包的lbuf空间
*
* @param [in] lbuf lbuf_alloc()返回用于存储数据包的地址
*
* @return 0则释放失败存在地址越界操作或者通道还没有被读完ref-1,读完后才能完全释放。1则释放成功。
*/
/* --------------------------------------------------------------------------*/
int lbuf_free(void *lbuf);
/* --------------------------------------------------------------------------*/
/**
* @brief 用于调试,检查是否可以释放存储数据包的lbuf空间
*
* @param [in] lbuf lbuf_alloc()返回用于存储数据包的地址
* @param [in] rets 调用lbuf_free_check()函数的返回地址rets,取值可参考lbuf_free()
*/
/* --------------------------------------------------------------------------*/
void lbuf_free_check(void *lbuf, u32 rets);
/* --------------------------------------------------------------------------*/
/**
* @brief 返回可分配的用来存储数据包的最大lbuf内存空间
*
* @param [in] head lbuf操作句柄
*
* @return 可分配的最大lbuf内存空间的字节长度
*/
/* --------------------------------------------------------------------------*/
u32 lbuf_free_space(struct lbuff_head *head);
/* --------------------------------------------------------------------------*/
/**
* @brief 获取lbuf空间的状态
*
* @param [in] head lbuf操作句柄
* @param [out] state lbuff_state结构体
*/
/* --------------------------------------------------------------------------*/
void lbuf_state(struct lbuff_head *head, struct lbuff_state *state);
/* --------------------------------------------------------------------------*/
/**
* @brief lbuf信息打印
*
* @param [in] head lbuf操作句柄
*/
/* --------------------------------------------------------------------------*/
void lbuf_dump(struct lbuff_head *head);
/* --------------------------------------------------------------------------*/
/**
* @brief 获取已经存入lbuf空间的数据包的数量
*
* @param [in] head lbuf操作句柄
*
* @return lbuf存储的数据包的数量
*/
/* --------------------------------------------------------------------------*/
int lbuf_traversal(struct lbuff_head *head);
/* --------------------------------------------------------------------------*/
/**
* @brief 返回lbuf空间还可以被写入size大小数据包的数量
*
* @param [in] head lbuf操作句柄
* @param [in] size 欲检测写入数据包的大小
*
* @return 可以写入的数量
*/
/* --------------------------------------------------------------------------*/
int lbuf_avaliable(struct lbuff_head *head, int size);
/* --------------------------------------------------------------------------*/
/**
* @brief 返回给数据包分配的内存空间的大小
*
* @param [in] lbuf lbuf_alloc()返回用于存储数据包的地址
*
* @return 实际占用空间的字节长度
*/
/* --------------------------------------------------------------------------*/
int lbuf_real_size(void *lbuf);
/* --------------------------------------------------------------------------*/
/**
* @brief 计算lbuf空间剩下多少剩余空间
*
* @param [in] head lbuf操作句柄
*
* @return 剩余空间的字节长度
*/
/* --------------------------------------------------------------------------*/
int lbuf_remain_space(struct lbuff_head *head);
/* --------------------------------------------------------------------------*/
/**
* @brief 需要被重复释放的次数+1
*
* @param [in] lbuf lbuf_alloc()返回用于存储数据包的地址
*/
/* --------------------------------------------------------------------------*/
void lbuf_inc_ref(void *lbuf);
#endif

View File

@ -0,0 +1,50 @@
#ifndef LBUF_LITE_H
#define LBUF_LITE_H
#include "typedef.h"
#include "list.h"
#include "system/spinlock.h"
struct lbuff_lite_head {
int magic_a;
struct list_head head;
struct list_head free;
spinlock_t lock;
u8 align;
u16 priv_len;
u32 total_size;
u32 last_addr;
void *priv;
int magic_b;
};
struct lbuff_lite_state {
u32 avaliable;
u32 fragment;
u32 max_continue_len;
int num;
};
struct lbuff_lite_head *lbuf_lite_init(void *buf, u32 len, int align, int priv_head_len);
void *lbuf_lite_alloc(struct lbuff_lite_head *head, u32 len);
void *lbuf_lite_realloc(void *lbuf, int size);
void lbuf_lite_free(void *lbuf);
u32 lbuf_lite_free_space(struct lbuff_lite_head *head);
void lbuf_lite_state(struct lbuff_lite_head *head, struct lbuff_lite_state *state);
void lbuf_lite_dump(struct lbuff_lite_head *head);
int lbuf_lite_avaliable(struct lbuff_lite_head *head, int size);
#endif

View File

@ -0,0 +1,291 @@
#ifndef LIST_H
#define LIST_H
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
* @type: the type of the container struct this is embedded in.
* @member: the name of the member within the struct.
*
*/
#ifdef list_offsetof
#undef list_offsetof
#endif
#ifdef container_of
#undef container_of
#endif
#define list_offsetof(type, memb) \
((unsigned long)(&((type *)0)->memb))
#define container_of(ptr, type, memb) \
((type *)((char *)(ptr) - list_offsetof(type, memb)))
struct list_head {
struct list_head *next, *prev;
};
#define LIST_HEAD_INIT(name) { &(name), &(name) }
#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)
/**
* list_entry - get the struct for this entry
* @ptr: the &struct list_head pointer.
* @type: the type of the struct this is embedded in.
* @member: the name of the list_struct within the struct.
*/
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)
/**
* list_first_entry - get the first element from a list
* @ptr: the list head to take the element from.
* @type: the type of the struct this is embedded in.
* @member: the name of the list_struct within the struct.
*
* Note, that list is expected to be not empty.
*/
/* REF_LIST: spi.c */
#define list_first_entry(ptr, type, member) \
list_entry((ptr)->next, type, member)
/**
* list_for_each - iterate over a list
* @pos: the &struct list_head to use as a loop cursor.
* @head: the head for your list.
*/
#define list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); \
pos = pos->next)
/**
* list_for_each_safe - iterate over a list safe against removal of list entry
* @pos: the &struct list_head to use as a loop counter.
* @n: another &struct list_head to use as temporary storage
* @head: the head for your list.
*/
#define list_for_each_safe(pos, n, head) \
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
/**
* list_for_each_entry - iterate over list of given type
* @pos: the type * to use as a loop cursor.
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define list_for_each_entry(pos, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))
/**
* list_for_each_entry_reverse - iterate backwards over list of given type.
* @pos: the type * to use as a loop cursor.
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define list_for_each_entry_reverse(pos, head, member) \
for (pos = list_entry((head)->prev, typeof(*pos), member); \
&pos->member != (head); \
pos = list_entry(pos->member.prev, typeof(*pos), member))
/**
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
* @pos: the type * to use as a loop cursor.
* @n: another type * to use as temporary storage
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define list_for_each_entry_safe(pos, n, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member), \
n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.next, typeof(*n), member))
#define list_for_each_entry_reverse_safe(pos, n, head, member) \
for (pos = list_entry((head)->prev, typeof(*pos), member), \
n = list_entry(pos->member.prev, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(n->member.prev, typeof(*n), member))
/**
* list_empty - tests whether a list is empty
* @head: the list to test.
*/
/* REF_LIST: spi.c */
static inline int list_empty(const struct list_head *head)
{
return head->next == head;
}
/*
* Insert a new entry between two known consecutive entries.
*
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
static inline void __list_add(struct list_head *_new,
struct list_head *prev,
struct list_head *next)
{
next->prev = _new;
_new->next = next;
_new->prev = prev;
prev->next = _new;
}
/**
* list_add_tail - add a new entry
* @new: new entry to be added
* @head: list head to add it before
*
* Insert a new entry before the specified head.
* This is useful for implementing queues.
*/
/* REF_LIST: spi.c */
static inline void list_add_tail(struct list_head *_new, struct list_head *head)
{
__list_add(_new, head->prev, head);
}
static inline void __list_del(struct list_head *prev, struct list_head *next)
{
next->prev = prev;
prev->next = next;
}
static inline void __list_del_entry(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
}
/* REF_LIST: spi.c */
static inline void list_del(struct list_head *entry) //修改过的list_del这里与list_del_init一样
{
__list_del(entry->prev, entry->next);
entry->next = entry;
entry->prev = entry;
}
/*
* Simple doubly linked list implementation.
*
* Some of the internal functions ("__xxx") are useful when
* manipulating whole lists rather than single entries, as
* sometimes we already know the next/prev entries and we can
* generate better code by using them directly rather than
* using the generic single-entry routines.
*/
static inline void INIT_LIST_HEAD(struct list_head *list)
{
list->next = list;
list->prev = list;
}
static inline void list_del_init(struct list_head *entry)
{
__list_del_entry(entry);
INIT_LIST_HEAD(entry);
}
/**
* list_move_tail - delete from one list and add as another's tail
* @list: the entry to move
* @head: the head that will follow our entry
*/
static inline void list_move_tail(struct list_head *list,
struct list_head *head)
{
__list_del(list->prev, list->next);
list_add_tail(list, head);
}
/**
* list_add - add a new entry
* @new: new entry to be added
* @head: list head to add it after
*
* Insert a new entry after the specified head.
* This is good for implementing stacks.
*/
static inline void list_add(struct list_head *new, struct list_head *head)
{
__list_add(new, head, head->next);
}
static inline int list_is_head(struct list_head *head, struct list_head *member)
{
return head->next == member;
}
#if 0
static inline void __list_splice(const struct list_head *list,
struct list_head *prev,
struct list_head *next)
{
struct list_head *first = list->next;
struct list_head *last = list->prev;
first->prev = prev;
prev->next = first;
last->next = next;
next->prev = last;
}
/**
* list_splice_tail_init - join two lists and reinitialise the emptied list
* @list: the new list to add.
* @head: the place to add it in the first list.
*
* Each of the lists is a queue.
* The list at @list is reinitialised
*/
static inline void list_splice_tail_init(struct list_head *list,
struct list_head *head)
{
if (!list_empty(list)) {
__list_splice(list, head->prev, head);
INIT_LIST_HEAD(list);
}
}
/**
* list_is_singular - tests whether a list has just one entry.
* @head: the list to test.
*/
static inline int list_is_singular(const struct list_head *head)
{
return !list_empty(head) && (head->next == head->prev);
}
/**
* list_splice_tail - join two lists, each list being a queue
* @list: the new list to add.
* @head: the place to add it in the first list.
*/
static inline void list_splice_tail(struct list_head *list,
struct list_head *head)
{
if (!list_empty(list)) {
__list_splice(list, head->prev, head);
}
}
#endif
#define list_for_each_entry_from(pos, head, member) \
for (; &pos->member != (head); \
pos = list_entry(pos->member.next, typeof(*pos), member))
#define list_for_each_entry_from_reverse(pos, head, member) \
for (; &pos->member != (head); \
pos = list_entry(pos->member.prev, typeof(*pos), member))
#endif

View File

@ -0,0 +1,127 @@
#ifndef __LOG_H
#define __LOG_H
#include "system/generic/printf.h"
#define __LOG_VERB 0
#define __LOG_DEBUG 1
#define __LOG_INFO 2
#define __LOG_WARN 3
#define __LOG_ERROR 4
#define __LOG_CHAR 5
struct logbuf {
u16 len;
u16 buf_len;
char buf[0];
};
#define __LOG_ENABLE
#ifndef __LOG_LEVEL
#define __LOG_LEVEL 0
#endif
#ifdef CONFIG_RELEASE_ENABLE
#undef __LOG_LEVEL
#define __LOG_LEVEL 0xff
#endif
#if __LOG_LEVEL > __LOG_VERB
#define log_v(...) do {} while (0)
#elif defined __LOG_ENABLE
#define log_v(...) log_print(__LOG_VERB, NULL, __VA_ARGS__)
#else
#define log_v(...) printf(__VA_ARGS__)
#endif
#if __LOG_LEVEL > __LOG_DEBUG
#define log_d(...) do {} while (0)
#elif defined __LOG_ENABLE
#define log_d(...) log_print(__LOG_DEBUG, NULL, __VA_ARGS__);
#else
#define log_d(...) printf(__VA_ARGS__)
#endif
#if __LOG_LEVEL > __LOG_INFO
#define log_i(...) do {} while (0)
#elif defined __LOG_ENABLE
#define log_i(...) log_print(__LOG_INFO, NULL, __VA_ARGS__);
#else
#define log_i(...) printf(__VA_ARGS__)
#endif
#if __LOG_LEVEL > __LOG_WARN
#define log_w(...) do {} while (0)
#elif defined __LOG_ENABLE
#define log_w(...) log_print(__LOG_WARN, NULL, __VA_ARGS__);
#else
#define log_w(...) printf(__VA_ARGS__)
#endif
#if __LOG_LEVEL > __LOG_ERROR
#define log_e(...) do {} while (0)
#elif defined __LOG_ENABLE
#define log_e(...) log_print(__LOG_ERROR, NULL, __VA_ARGS__);
#else
#define log_e(...) printf(__VA_ARGS__)
#endif
#if __LOG_LEVEL > __LOG_CHAR
#define log_c(x) do {} while (0)
#elif defined __LOG_ENABLE
#define log_c(x) putchar(x)
#else
#define log_c(x)
#endif
#define r_printf(x, ...) log_i("\e[31m\e[1m" x "\e[0m", ## __VA_ARGS__)
#define g_printf(x, ...) log_i("\e[32m\e[1m" x "\e[0m", ## __VA_ARGS__)
#define y_printf(x, ...) log_i("\e[33m\e[1m" x "\e[0m", ## __VA_ARGS__)
#define r_f_printf(x, ...) log_i("\e[31m\e[5m\e[1m" x "\e[0m", ## __VA_ARGS__)
#define g_f_printf(x, ...) log_i("\e[32m\e[5m\e[1m" x "\e[0m", ## __VA_ARGS__)
#define y_f_printf(x, ...) log_i("\e[33m\e[5m\e[1m" x "\e[0m", ## __VA_ARGS__)
#ifndef __LOG_ENABLE
#define log_dump(a, b) do {} while(0)
#define log_putchar() do {} while(0)
#define log_early_init(a) do {} while(0)
#define log_level(a) do {} while(0)
#else
int log_output_lock();
void log_output_unlock();
void log_print_time();
void log_early_init(int buf_size);
void log_level(int level);
void log_print(int level, const char *tag, const char *format, ...);
void log_dump(const u8 *buf, int len);
struct logbuf *log_output_start(int len);
void log_output_end(struct logbuf *);
void log_putchar(struct logbuf *lb, char c);
void log_put_u8hex(struct logbuf *lb, unsigned char dat);
void log_putbyte(char);
void log_set_time_offset(int offset);
int log_get_time_offset();
#endif
void log_flush();
#endif

View File

@ -0,0 +1,28 @@
#ifndef _PRINTF_H_
#define _PRINTF_H_
#define line_inf printf("%s %s %d \r\n" ,__FILE__, __func__ , __LINE__) ;
#include <stdarg.h>
#include "typedef.h"
//#define NOFLOAT
extern int putchar(int a);
extern int puts(const char *out);
void put_u4hex(unsigned char dat);
void put_u8hex(unsigned char dat);
void put_u16hex(unsigned short dat);
void put_u32hex(unsigned int dat);
void put_buf(const u8 *buf, int len);
int printf(const char *format, ...);
int assert_printf(const char *format, ...);
int sprintf(char *out, const char *format, ...);
int vprintf(const char *fmt, __builtin_va_list va);
int vsnprintf(char *, unsigned long, const char *, __builtin_va_list);
int snprintf(char *buf, unsigned long size, const char *fmt, ...);
int print(char **out, char *end, const char *format, va_list args);
//int snprintf(char *, unsigned long, const char *, ...);
int sscanf(const char *buf, const char *fmt, ...); //BUG: 多个参数? 最后又空格?
//int perror(const char *fmt, ...);
#endif

View File

@ -0,0 +1,134 @@
#ifndef RECT_H
#define RECT_H
#include "typedef.h"
#define AT_UI_RAM AT(.ui_ram)
struct position {
int x;
int y;
};
struct rect {
int left;
int top;
int width;
int height;
};
#define rect_left(r) ((r)->left)
#define rect_top(r) ((r)->top)
#define rect_right(r) ((r)->left + (r)->width)
#define rect_bottom(r) ((r)->top + (r)->height)
//#define rect_height(v) ((v)->bottom - (v)->top)
//#define rect_width(v) ((v)->right - (v)->left)
static inline int in_rect(const struct rect *rect, struct position *pos)
{
if (rect->left <= pos->x && rect_right(rect) > pos->x) {
if (rect->top <= pos->y && rect_bottom(rect) > pos->y) {
return true;
}
}
return false;
}
AT_UI_RAM
static inline bool get_rect_cover(const struct rect *a, const struct rect *b, struct rect *c)
{
int right, bottom;
c->top = MAX(a->top, b->top);
c->left = MAX(a->left, b->left);
right = MIN(rect_right(a), rect_right(b));
bottom = MIN(rect_bottom(a), rect_bottom(b));
if ((c->top < bottom) && (c->left < right)) {
c->width = right - c->left;
c->height = bottom - c->top;
return true;
}
return false;
}
static inline bool get_rect_nocover_l(const struct rect *a, const struct rect *b, struct rect *c)
{
int right, bottom;
c->left = MIN(rect_left(a), rect_left(b));
c->top = MIN(rect_top(a), rect_top(b));
right = MAX(rect_left(a), rect_left(b));
bottom = MAX(rect_bottom(a), rect_bottom(b));
if ((c->top < bottom) && (c->left < right)) {
c->width = right - c->left;
c->height = bottom - c->top;
return true;
}
return false;
}
static inline bool get_rect_nocover_r(const struct rect *a, const struct rect *b, struct rect *c)
{
int right, bottom;
c->left = MIN(rect_right(a), rect_right(b));
c->top = MIN(rect_top(a), rect_top(b));
right = MAX(rect_right(a), rect_right(b));
bottom = MAX(rect_bottom(a), rect_bottom(b));
if ((c->top < bottom) && (c->left < right)) {
c->width = right - c->left;
c->height = bottom - c->top;
return true;
}
return false;
}
static inline bool get_rect_nocover_t(const struct rect *a, const struct rect *b, struct rect *c)
{
int right, bottom;
c->left = MIN(rect_left(a), rect_left(b));
c->top = MIN(rect_top(a), rect_top(b));
right = MAX(rect_right(a), rect_right(b));
bottom = MAX(rect_top(a), rect_top(b));
if ((c->top < bottom) && (c->left < right)) {
c->width = right - c->left;
c->height = bottom - c->top;
return true;
}
return false;
}
static inline bool get_rect_nocover_b(const struct rect *a, const struct rect *b, struct rect *c)
{
int right, bottom;
c->left = MIN(rect_left(a), rect_left(b));
c->top = MIN(rect_bottom(a), rect_bottom(b));
right = MAX(rect_right(a), rect_right(b));
bottom = MAX(rect_bottom(a), rect_bottom(b));
if ((c->top < bottom) && (c->left < right)) {
c->width = right - c->left;
c->height = bottom - c->top;
return true;
}
return false;
}
#endif

View File

@ -0,0 +1,167 @@
/*************************************************************
File: typedef.h
Author:Juntham
Discriptor:
数据类型重定义
Version:
Date
*************************************************************/
#ifndef _typedef_h_
#define _typedef_h_
#include "asm/cpu.h"
#if defined(__GNUC__)
///<locate code to x segment ever exist
#define SEC_USED(x) __attribute__((section(#x),used))
///<locate code to x segment optimized by dependency
#define SEC(x) __attribute__((section(#x)))
#define sec(x) __attribute__((section(#x),used))
///<locate data to x segment
#define AT(x) __attribute__((section(#x)))
#define SET(x) __attribute__((x))
#define ALIGNED(x) __attribute__((aligned(x)))
#define _GNU_PACKED_ __attribute__((packed))
#define _NOINLINE_ __attribute__((noinline))
#define _INLINE_ __attribute__((always_inline))
#define _WEAK_ __attribute__((weak))
#define _WEAKREF_ __attribute__((weakref))
#define _NORETURN_ __attribute__((noreturn))
#define _NAKED_ __attribute__((naked))
#else
#define SEC_USED(x)
#define SEC(x)
#define AT(x)
#define SET(x)
#define ALIGNED(x)
#define _GNU_PACKED_
#define _NOINLINE_
#define _INLINE_
#define _WEAK_
#define _WEAKREF_
#define _NORETURN_
#define _NAKED_
#endif
#if CPU_ENDIAN == LITTLE_ENDIAN
//#define ntohl(x) (u32)((x>>24)|((x>>8)&0xff00)|(x<<24)|((x&0xff00)<<8))
//#define ntoh(x) (u16)((x>>8&0x00ff)|x<<8&0xff00)
//#define ntohl(x) (u32)((((u32)(x))>>24) | ((((u32)(x))>>8)&0xff00) | (((u32)(x))<<24) | ((((u32)(x))&0xff00)<<8))
//#define ntoh(x) (u16)((((u32)(x))>>8&0x00ff) | (((u32)(x))<<8&0xff00))
//#define NTOH(x) (x) = ntoh(x)
//#define NTOHL(x) (x) = ntohl(x)
#define LD_WORD(ptr) (u16)(*(u16*)(u8*)(ptr))
#define LD_DWORD(ptr) (u32)(*(u32*)(u8*)(ptr))
#define ST_WORD(ptr,val) *(u16*)(u8*)(ptr)=(u16)(val)
#define ST_DWORD(ptr,val) *(u32*)(u8*)(ptr)=(u32)(val)
#else
#define ntohl(x) (x)
#define ntoh(x) (x)
#define NTOH(x) (x) = ntoh(x)
#define NTOHL(x) (x) = ntohl(x)
#endif
#undef FALSE
#define FALSE 0
#undef TRUE
#define TRUE 1
#define false 0
#define true 1
#ifndef NULL
#define NULL (void *)0
#endif
#define BIT(n) (1UL << (n))
#define BitSET(REG,POS) ((REG) |= (1L << (POS)))
#define BitCLR(REG,POS) ((REG) &= (~(1L<< (POS))))
#define BitXOR(REG,POS) ((REG) ^= (~(1L << (POS))))
#define BitCHK_1(REG,POS) (((REG) & (1L << (POS))) == (1L << (POS)))
#define BitCHK_0(REG,POS) (((REG) & (1L << (POS))) == 0x00)
#define testBit(REG,POS) ((REG) & (1L << (POS)))
#define clrBit(x,y) (x) &= ~(1L << (y))
#define setBit(x,y) (x) |= (1L << (y))
#define readb(addr) *((volatile unsigned char*)(addr))
#define readw(addr) *((volatile unsigned short *)(addr))
#define readl(addr) *((volatile unsigned long*)(addr))
#define writeb(addr, val) *((volatile unsigned char*)(addr)) = (u8)(val)
#define writew(addr, val) *((volatile unsigned short *)(addr)) = (u16)(val)
#define writel(addr, val) *((volatile unsigned long*)(addr)) = (u32)(val)
#define ALIGN_4BYTE(size) ((size+3)&0xfffffffc)
#if CPU_ENDIAN == BIG_ENDIAN
#define __cpu_u16(lo, hi) ((lo)|((hi)<<8))
#elif CPU_ENDIAN == LITTLE_ENDIAN
#define __cpu_u16(lo, hi) ((hi)|((lo)<<8))
#else
#error "undefine cpu eadin"
#endif
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#define ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0]))
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#define SFR(sfr, start, len, dat) \
(sfr = (sfr & ~((~(0xffffffff << (len))) << (start))) | \
(((dat) & (~(0xffffffff << (len)))) << (start)))
#include "generic/errno-base.h"
#include "string.h"
#include "strings.h"
#include "system/malloc.h"
#ifdef offsetof
#undef offsetof
#endif
#ifdef container_of
#undef container_of
#endif
#define offsetof(type, memb) \
((unsigned long)(&((type *)0)->memb))
#define container_of(ptr, type, memb) \
((type *)((char *)(ptr) - offsetof(type, memb)))
void delay(unsigned int);
void delay_us(unsigned int);
#endif

View File

@ -0,0 +1,133 @@
#ifndef VERSION_H
#define VERSION_H
#include "typedef.h"
typedef int (*version_t)(int);
//定义模块的版本号,由主版本号和次版本号组成
//如果两个模块的主版本号相同即表示兼容
#define VERSION(major, minor) (((major)<<8) | (minor))
#define MAJOR(v) ((v) >> 16)
#define MINOR(v) (((v) >> 8) & 0xff)
#define version_match(module_a, module_b) \
({ \
extern int module_a##_version(int ); \
extern int module_b##_version(int ); \
int version_a = module_a##_version(0); \
int version_b = module_b##_version(0); \
MAJOR(version_a) == MAJOR(version_b);\
})
#define __MODULE_VERSION_EXPORT_BEGIN(module, version) \
int module##_version(int prt) \
{ \
if (prt) { \
log_i(#module": %d.%d.%d build at: %s\n", (version)>>16, \
((version) >> 8) & 0xff, (version) & 0xff, __DATE__); \
} \
#define __MODULE_VERSION_EXPORT_END(module, version) \
return version; \
} \
const version_t __version_##module \
__attribute__((section(".lib_version"),used)) = module##_version
#define __MODULE_VERSION_EXPORT(module, version) \
__MODULE_VERSION_EXPORT_BEGIN(module, version) \
__MODULE_VERSION_EXPORT_END(module, version);
#define __MODULE_VERSION_EXPORT_SECTION(module, version, section) \
__MODULE_VERSION_EXPORT_BEGIN(module, version) \
(void *)&section; \
__MODULE_VERSION_EXPORT_END(module, version)
#define __MODULE_DEPEND_BEGIN(module) \
int module##_version_check() \
{ \
#define _MODULE_DEPEND_BEGIN(module) \
__MODULE_DEPEND_BEGIN(module)
#define __VERSION_CHECK(module, version) \
do { \
int module##_version(int prt); \
int v = module##_version(0); \
if (MAJOR(version) != MAJOR(v) || MINOR(version) > MINOR(v)) { \
log_i("=======version not match=======\n"); \
module##_version(1); \
log_i("==================================\n"); \
while(1); \
} \
} while(0)
/*-------------------上面的宏请勿调用------------------------------------*/
//定义当前模块的版本检测函数
#define MODULE_VERSION_EXPORT(module, version) \
__MODULE_VERSION_EXPORT(module, version)
#define MODULE_VERSION_EXPORT_SECTION(module, version, section) \
__MODULE_VERSION_EXPORT_SECTION(module, version, section)
#define MODULE_VERSION_EXPORT_BEGIN(module, version) \
__MODULE_VERSION_EXPORT_BEGIN(module, version)
#define MODULE_VERSION_EXPORT_END(module, version) \
__MODULE_VERSION_EXPORT_END(module, version)
//以下3个宏定义当前模块依赖的其它模块列表
#define MODULE_DEPEND_BEGIN() \
_MODULE_DEPEND_BEGIN(THIS_MODULE)
#define MODULE_DEPEND(module_d, version) \
__VERSION_CHECK(module_d, version)
#define MODULE_DEPEND_END() \
return 0; \
}
#define VERSION_CHECK(module, version) \
__VERSION_CHECK(module, version)
//通过调用版本检测函数使的模块的代码能够被链接
#define load_module(module) \
({ \
int ret; \
extern int module##_version_check(); \
ret = module##_version_check();\
ret; \
})
extern version_t lib_version_begin[], lib_version_end[];
#define lib_version_check() \
do { \
version_t *version; \
log_i("=========version check===========\n"); \
for (version = lib_version_begin; version < lib_version_end; version++) { \
(*version)(1); \
}; \
log_i("==================================\n\n"); \
} while (0)
#endif

View File

@ -0,0 +1,30 @@
#ifndef SYS_INCLUDES_H
#define SYS_INCLUDES_H
#include "init.h"
#include "event.h"
#include "malloc.h"
#include "spinlock.h"
#include "task.h"
#include "timer.h"
#include "wait.h"
#include "app_core.h"
#include "app_msg.h"
#include "database.h"
#include "fs/fs.h"
#include "power_manage.h"
#include "syscfg_id.h"
#include "bank_switch.h"
#include "generic/includes.h"
#include "device/includes.h"
#include "asm/includes.h"
#include "device/sdio_host_init.h"
#endif

49
include_lib/system/init.h Normal file
View File

@ -0,0 +1,49 @@
#ifndef SYS_INIT_H
#define SYS_INIT_H
typedef int (*initcall_t)(void);
#define __initcall(fn) \
const initcall_t __initcall_##fn sec(.initcall) = fn
#define early_initcall(fn) \
const initcall_t __initcall_##fn sec(.early.initcall) = fn
#define late_initcall(fn) \
const initcall_t __initcall_##fn sec(.late.initcall) = fn
#define platform_initcall(fn) \
const initcall_t __initcall_##fn sec(.platform.initcall) = fn
#define module_initcall(fn) \
const initcall_t __initcall_##fn sec(.module.initcall) = fn
#define __do_initcall(prefix) \
do { \
initcall_t *init; \
extern initcall_t prefix##_begin[], prefix##_end[]; \
for (init=prefix##_begin; init<prefix##_end; init++) { \
(*init)(); \
} \
}while(0)
#endif

View File

@ -0,0 +1,34 @@
#ifndef _MEM_HEAP_H_
#define _MEM_HEAP_H_
#ifdef __cplusplus
extern "C" {
#endif
extern void *malloc(size_t size);
extern void *zalloc(size_t size);
extern void *calloc(size_t count, size_t size);
extern void *realloc(void *rmem, size_t newsize);
extern void free(void *mem);
extern void *kmalloc(size_t size, int flags);
extern void *vmalloc(size_t size);
extern void vfree(void *addr);
extern void *kzalloc(unsigned int len, int a);
extern void kfree(void *p);
extern void malloc_stats(void);
extern void malloc_dump();
void memory_init(void);
void mem_stats(void);
#ifdef __cplusplus
}
#endif
#endif /* _MEM_HEAP_H_ */

View File

@ -0,0 +1,137 @@
#ifndef MatrixInteFunc_H
#define MatrixInteFunc_H
#include "stdio.h"
// DW_Width define
#define DW_8 1 //001
#define DW_16 2 //010
#define DW_32 4 //100
// Real define
#define MATR_ADD 17 //010001
#define MATR_SUB 25 //011001
#define MATR_SCALEADD 19 //010011
#define MATR_SCALESUB 27 //011011
#define MATR_SCALEMUL 33 //100001
#define MATR_SCALEMLA 35 //100011
#define MATR_SCALEMLS 43 //101011
#define MATRVECT_MUL 37 //100101
// Complex define
#define MATC_ADD 16 //010000
#define MATC_SUB 24 //011000
#define MATC_SCALEADD 18 //010010
#define MATC_SCALESUB 26 //011010
#define MATC_CSCALEMUL 30 //011110
#define MATC_SCALEMUL 32 //100000
#define MATC_SCALEMLA 34 //100010
#define MATC_SCALEMLS 42 //101010
#define MATCVECT_MUL 36 //100100
//struct define for parameter configuration
typedef struct {
unsigned short MatRow;
unsigned short MatCol;
unsigned short MatQ;
unsigned int RS;
} MC;
typedef struct {
unsigned int MatAdr;
unsigned short RowStep;
unsigned short ColStep;
unsigned short Conj;
unsigned short Dw;
} MXYZ;
//Hardware parameter configuration structure
typedef struct {
unsigned int matrix_con;
unsigned int matrix_xadr;
unsigned int matrix_yadr;
unsigned int matrix_zadr;
unsigned int matrix_rs;
unsigned int matrix_xconfig;
unsigned int matrix_yconfig;
unsigned int matrix_zconfig;
} matrix_config;
/*
typedef struct
{
volatile unsigned int CON;
volatile unsigned int CADR;
volatile unsigned int ACC0H;
volatile unsigned int ACC0L;
volatile unsigned int ACC1H;
volatile unsigned int ACC1L;
} JL_FFT_TypeDef;
#define JL_FFT_BASE 0x102000
#define JL_FFT ((JL_FFT_TypeDef *)JL_FFT_BASE)
*/
//*********** Z = Y + X ***********//
void MatrixADD_Real(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z = Y - X ***********//
void MatrixSUB_Real(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z = Y + X*RS/(2^Q) ***********//
void MatrixScaleADD_Real(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z = Y - X*RS/(2^Q) ***********//
void MatrixScaleSUB_Real(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z = Y .* X/(2^Q) ***********//
void MatrixScaleMUL_Real(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z = Z + Y .* X/(2^Q) ***********//
void MatrixScaleMLA_Real(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z = Z - Y .* X/(2^Q) ***********//
void MatrixScaleMLS_Real(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z_r = Y_v .* X_v ***********//
void MatVecMUL_Real(MXYZ *mx, MXYZ *my, int *rst, MC *mc, int rQ);
//*********** Z = Y * X ***********//
void MatrixMUL_Real(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc, int rQ);
//*********** Z = Y + X (Complex) ***********//
void MatrixADD_Complex(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z = Y - X (Complex) ***********//
void MatrixSUB_Complex(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z = Y + X*RS/(2^Q) (Complex) ***********//
void MatrixScaleADD_Complex(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z = Y - X*RS/(2^Q) (Complex) ***********//
void MatrixScaleSUB_Complex(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z_c = Y_c .* X_r/(2^Q) (Complex) ***********//
void MatrixComplexScaleMUL_Complex(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z = Y .* X/(2^Q) (Complex) ***********//
void MatrixScaleMUL_Complex(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z = Z + Y .* X/(2^Q) (Complex) ***********//
void MatrixScaleMLA_Complex(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z = Z - Y .* X/(2^Q) (Complex) ***********//
void MatrixScaleMLS_Complex(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc);
//*********** Z_r = Y_v .* X_v (Complex) ***********//
void MatVecMUL_Complex(MXYZ *mx, MXYZ *my, int *rst, MC *mc, int rQ);
//*********** Z = Y * X (Complex) ***********//
void MatrixMUL_Complex(MXYZ *mx, MXYZ *my, MXYZ *mz, MC *mc, int rQ);
#endif

View File

@ -0,0 +1,54 @@
#ifndef MATH_FAST_FUNCTION
#define MATH_FAST_FUNCTION
#ifndef MATH_USE_LIMIT
#define MATH_USE_LIMIT 1
#endif
struct data_q_struct {
long data;
char q;
};
extern long cos_fix(long x);
extern float cos_float(float x);
extern long sin_fix(long x);
extern float sin_float(float x);
extern struct data_q_struct complex_abs_fix(long x, long y);
extern struct data_q_struct complex_dqdt_fix(long x, long y);
extern float complex_abs_float(float x, float y);
extern float complex_dqdt_float(float x, float y);
extern struct data_q_struct root_fix(struct data_q_struct x);
extern float root_float(float x);
extern struct data_q_struct mul_fix(long x, long y);
extern float mul_float(float x, float y);
extern struct data_q_struct div_fix(long x, long y);
extern float div_float(float x, float y);
extern struct data_q_struct exp_fix(long x);
extern float exp_float(float x);
extern struct data_q_struct ln_fix(struct data_q_struct x);
extern float ln_float(float x);
extern struct data_q_struct angle_fix(long x, long y);
extern float angle_float(float x, float y);
extern struct data_q_struct atanh_fix(long x, long y);
extern float atanh_float(float x, float y);
extern long cosh_fix(long x);
extern float cosh_float(float x);
extern long sinh_fix(long x);
extern float sinh_float(float x);
extern struct data_q_struct log10_fix(struct data_q_struct x);
extern float log10_float(float x);
extern struct data_q_struct sigmoid_fix(float x);
extern float sigmoid_float(float x);
extern struct data_q_struct tanh_fix(float x);
extern float tanh_float(float x);
float dB_Convert_Mag(float x);
//==== add for limit input data range ====//
extern float atanh_float_limit(float x, float y);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,195 @@
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
* Application specific definitions.
*
* These definitions should be adjusted for your particular hardware and
* application requirements.
*
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. See
* http://www.freertos.org/a00110.html
*----------------------------------------------------------*/
#define configUSE_PREEMPTION 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
#define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 0
#define configUSE_DAEMON_TASK_STARTUP_HOOK 1
#define configTICK_RATE_HZ ( 100 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */
#define configMINIMAL_STACK_SIZE ( ( unsigned int) 256) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 30 * 1024 ) )
#define configMAX_TASK_NAME_LEN ( 12 )
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_MUTEXES 1
#define configCHECK_FOR_STACK_OVERFLOW 0
#define configUSE_RECURSIVE_MUTEXES 1
#define configQUEUE_REGISTRY_SIZE 0
#define configUSE_MALLOC_FAILED_HOOK 1
#define configUSE_APPLICATION_TASK_TAG 1
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_ALTERNATIVE_API 0
#define configUSE_QUEUE_SETS 0
#define configUSE_TASK_NOTIFICATIONS 0
#define configSUPPORT_STATIC_ALLOCATION 1
/* Software timer related configuration options. */
#define configUSE_TIMERS 0
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
#define configTIMER_QUEUE_LENGTH 20
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 2 )
#define configMAX_PRIORITIES ( 8 )
/* Run time stats gathering configuration options. */
unsigned long ulGetRunTimeCounterValue(void); /* Prototype of function that returns run time counter. */
void vConfigureTimerForRunTimeStats(void); /* Prototype of function that initialises the run time counter. */
void vMainConfigureTimerForRunTimeStats(void);
unsigned long ulMainGetRunTimeCounterValue(void);
#define configGENERATE_RUN_TIME_STATS 0
// #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vMainConfigureTimerForRunTimeStats();
#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()
/* Co-routine related configuration options. */
#define configUSE_CO_ROUTINES 1
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* This demo makes use of one or more example stats formatting functions. These
format the raw data provided by the uxTaskGetSystemState() function in to human
readable ASCII form. See the notes in the implementation of vTaskList() within
FreeRTOS/Source/tasks.c for limitations. */
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. In most cases the linker will remove unused
functions anyway. */
#define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1
#define INCLUDE_xTaskGetSchedulerState 1
#define INCLUDE_xTimerGetTimerDaemonTaskHandle 1
#define INCLUDE_xTaskGetIdleTaskHandle 1
#define INCLUDE_xTaskGetHandle 1
#define INCLUDE_eTaskGetState 1
#define INCLUDE_xSemaphoreGetMutexHolder 1
#define INCLUDE_xTimerPendFunctionCall 0
#define INCLUDE_xTaskAbortDelay 1
/* It is a good idea to define configASSERT() while developing. configASSERT()
uses the same semantics as the standard C assert() macro. */
#include "printf.h"
static inline void vAssertCalled(const char *str, unsigned int ulLine)
{
/*
if(OS_CPU_ID == 0)
{
C1_CON |=BIT(1) ;
}else
{
C0_CON |=BIT(1) ;
}*/
local_irq_disable();
printf("%s %d\n", str, ulLine) ;
while (1);
}
#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled(__func__, __LINE__)
/* Include the FreeRTOS+Trace FreeRTOS trace macro definitions. */
#define TRACE_ENTER_CRITICAL_SECTION() portENTER_CRITICAL()
#define TRACE_EXIT_CRITICAL_SECTION() portEXIT_CRITICAL()
//#include "trcKernelPort.h"
#ifdef __GCC_PI32V2__
#include "pi32v2/portmacro.h"
#endif
#ifdef __GCC_PI32_LTO__
#include "pi32_lto/portmacro.h"
#endif
#ifdef __GCC_Q32S__
#include "q32s/portmacro.h"
#endif
#endif /* FREERTOS_CONFIG_H */

View File

@ -0,0 +1,321 @@
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
#ifndef DEPRECATED_DEFINITIONS_H
#define DEPRECATED_DEFINITIONS_H
/* Each FreeRTOS port has a unique portmacro.h header file. Originally a
pre-processor definition was used to ensure the pre-processor found the correct
portmacro.h file for the port being used. That scheme was deprecated in favour
of setting the compiler's include path such that it found the correct
portmacro.h file - removing the need for the constant and allowing the
portmacro.h file to be located anywhere in relation to the port being used. The
definitions below remain in the code for backward compatibility only. New
projects should not use them. */
#ifdef OPEN_WATCOM_INDUSTRIAL_PC_PORT
#include "..\..\Source\portable\owatcom\16bitdos\pc\portmacro.h"
typedef void (__interrupt __far *pxISR)();
#endif
#ifdef OPEN_WATCOM_FLASH_LITE_186_PORT
#include "..\..\Source\portable\owatcom\16bitdos\flsh186\portmacro.h"
typedef void (__interrupt __far *pxISR)();
#endif
#ifdef GCC_MEGA_AVR
#include "../portable/GCC/ATMega323/portmacro.h"
#endif
#ifdef IAR_MEGA_AVR
#include "../portable/IAR/ATMega323/portmacro.h"
#endif
#ifdef MPLAB_PIC24_PORT
#include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h"
#endif
#ifdef MPLAB_DSPIC_PORT
#include "../../Source/portable/MPLAB/PIC24_dsPIC/portmacro.h"
#endif
#ifdef MPLAB_PIC18F_PORT
#include "../../Source/portable/MPLAB/PIC18F/portmacro.h"
#endif
#ifdef MPLAB_PIC32MX_PORT
#include "../../Source/portable/MPLAB/PIC32MX/portmacro.h"
#endif
#ifdef _FEDPICC
#include "libFreeRTOS/Include/portmacro.h"
#endif
#ifdef SDCC_CYGNAL
#include "../../Source/portable/SDCC/Cygnal/portmacro.h"
#endif
#ifdef GCC_ARM7
#include "../../Source/portable/GCC/ARM7_LPC2000/portmacro.h"
#endif
#ifdef GCC_ARM7_ECLIPSE
#include "portmacro.h"
#endif
#ifdef ROWLEY_LPC23xx
#include "../../Source/portable/GCC/ARM7_LPC23xx/portmacro.h"
#endif
#ifdef IAR_MSP430
#include "..\..\Source\portable\IAR\MSP430\portmacro.h"
#endif
#ifdef GCC_MSP430
#include "../../Source/portable/GCC/MSP430F449/portmacro.h"
#endif
#ifdef ROWLEY_MSP430
#include "../../Source/portable/Rowley/MSP430F449/portmacro.h"
#endif
#ifdef ARM7_LPC21xx_KEIL_RVDS
#include "..\..\Source\portable\RVDS\ARM7_LPC21xx\portmacro.h"
#endif
#ifdef SAM7_GCC
#include "../../Source/portable/GCC/ARM7_AT91SAM7S/portmacro.h"
#endif
#ifdef SAM7_IAR
#include "..\..\Source\portable\IAR\AtmelSAM7S64\portmacro.h"
#endif
#ifdef SAM9XE_IAR
#include "..\..\Source\portable\IAR\AtmelSAM9XE\portmacro.h"
#endif
#ifdef LPC2000_IAR
#include "..\..\Source\portable\IAR\LPC2000\portmacro.h"
#endif
#ifdef STR71X_IAR
#include "..\..\Source\portable\IAR\STR71x\portmacro.h"
#endif
#ifdef STR75X_IAR
#include "..\..\Source\portable\IAR\STR75x\portmacro.h"
#endif
#ifdef STR75X_GCC
#include "..\..\Source\portable\GCC\STR75x\portmacro.h"
#endif
#ifdef STR91X_IAR
#include "..\..\Source\portable\IAR\STR91x\portmacro.h"
#endif
#ifdef GCC_H8S
#include "../../Source/portable/GCC/H8S2329/portmacro.h"
#endif
#ifdef GCC_AT91FR40008
#include "../../Source/portable/GCC/ARM7_AT91FR40008/portmacro.h"
#endif
#ifdef RVDS_ARMCM3_LM3S102
#include "../../Source/portable/RVDS/ARM_CM3/portmacro.h"
#endif
#ifdef GCC_ARMCM3_LM3S102
#include "../../Source/portable/GCC/ARM_CM3/portmacro.h"
#endif
#ifdef GCC_ARMCM3
#include "../../Source/portable/GCC/ARM_CM3/portmacro.h"
#endif
#ifdef IAR_ARM_CM3
#include "../../Source/portable/IAR/ARM_CM3/portmacro.h"
#endif
#ifdef IAR_ARMCM3_LM
#include "../../Source/portable/IAR/ARM_CM3/portmacro.h"
#endif
#ifdef HCS12_CODE_WARRIOR
#include "../../Source/portable/CodeWarrior/HCS12/portmacro.h"
#endif
#ifdef MICROBLAZE_GCC
#include "../../Source/portable/GCC/MicroBlaze/portmacro.h"
#endif
#ifdef TERN_EE
#include "..\..\Source\portable\Paradigm\Tern_EE\small\portmacro.h"
#endif
#ifdef GCC_HCS12
#include "../../Source/portable/GCC/HCS12/portmacro.h"
#endif
#ifdef GCC_MCF5235
#include "../../Source/portable/GCC/MCF5235/portmacro.h"
#endif
#ifdef COLDFIRE_V2_GCC
#include "../../../Source/portable/GCC/ColdFire_V2/portmacro.h"
#endif
#ifdef COLDFIRE_V2_CODEWARRIOR
#include "../../Source/portable/CodeWarrior/ColdFire_V2/portmacro.h"
#endif
#ifdef GCC_PPC405
#include "../../Source/portable/GCC/PPC405_Xilinx/portmacro.h"
#endif
#ifdef GCC_PPC440
#include "../../Source/portable/GCC/PPC440_Xilinx/portmacro.h"
#endif
#ifdef _16FX_SOFTUNE
#include "..\..\Source\portable\Softune\MB96340\portmacro.h"
#endif
#ifdef BCC_INDUSTRIAL_PC_PORT
/* A short file name has to be used in place of the normal
FreeRTOSConfig.h when using the Borland compiler. */
#include "frconfig.h"
#include "..\portable\BCC\16BitDOS\PC\prtmacro.h"
typedef void (__interrupt __far *pxISR)();
#endif
#ifdef BCC_FLASH_LITE_186_PORT
/* A short file name has to be used in place of the normal
FreeRTOSConfig.h when using the Borland compiler. */
#include "frconfig.h"
#include "..\portable\BCC\16BitDOS\flsh186\prtmacro.h"
typedef void (__interrupt __far *pxISR)();
#endif
#ifdef __GNUC__
#ifdef __AVR32_AVR32A__
#include "portmacro.h"
#endif
#endif
#ifdef __ICCAVR32__
#ifdef __CORE__
#if __CORE__ == __AVR32A__
#include "portmacro.h"
#endif
#endif
#endif
#ifdef __91467D
#include "portmacro.h"
#endif
#ifdef __96340
#include "portmacro.h"
#endif
#ifdef __IAR_V850ES_Fx3__
#include "../../Source/portable/IAR/V850ES/portmacro.h"
#endif
#ifdef __IAR_V850ES_Jx3__
#include "../../Source/portable/IAR/V850ES/portmacro.h"
#endif
#ifdef __IAR_V850ES_Jx3_L__
#include "../../Source/portable/IAR/V850ES/portmacro.h"
#endif
#ifdef __IAR_V850ES_Jx2__
#include "../../Source/portable/IAR/V850ES/portmacro.h"
#endif
#ifdef __IAR_V850ES_Hx2__
#include "../../Source/portable/IAR/V850ES/portmacro.h"
#endif
#ifdef __IAR_78K0R_Kx3__
#include "../../Source/portable/IAR/78K0R/portmacro.h"
#endif
#ifdef __IAR_78K0R_Kx3L__
#include "../../Source/portable/IAR/78K0R/portmacro.h"
#endif
#endif /* DEPRECATED_DEFINITIONS_H */

View File

@ -0,0 +1,450 @@
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
/*
* This is the list implementation used by the scheduler. While it is tailored
* heavily for the schedulers needs, it is also available for use by
* application code.
*
* list_ts can only store pointers to list_item_ts. Each ListItem_t contains a
* numeric value (xItemValue). Most of the time the lists are sorted in
* descending item value order.
*
* Lists are created already containing one list item. The value of this
* item is the maximum possible that can be stored, it is therefore always at
* the end of the list and acts as a marker. The list member pxHead always
* points to this marker - even though it is at the tail of the list. This
* is because the tail contains a wrap back pointer to the true head of
* the list.
*
* In addition to it's value, each list item contains a pointer to the next
* item in the list (pxNext), a pointer to the list it is in (pxContainer)
* and a pointer to back to the object that contains it. These later two
* pointers are included for efficiency of list manipulation. There is
* effectively a two way link between the object containing the list item and
* the list item itself.
*
*
* \page ListIntroduction List Implementation
* \ingroup FreeRTOSIntro
*/
#ifndef INC_FREERTOS_H
#error FreeRTOS.h must be included before list.h
#endif
#ifndef FREERTOS_LIST_H
#define FREERTOS_LIST_H
/*
* The list structure members are modified from within interrupts, and therefore
* by rights should be declared volatile. However, they are only modified in a
* functionally atomic way (within critical sections of with the scheduler
* suspended) and are either passed by reference into a function or indexed via
* a volatile variable. Therefore, in all use cases tested so far, the volatile
* qualifier can be omitted in order to provide a moderate performance
* improvement without adversely affecting functional behaviour. The assembly
* instructions generated by the IAR, ARM and GCC compilers when the respective
* compiler's options were set for maximum optimisation has been inspected and
* deemed to be as intended. That said, as compiler technology advances, and
* especially if aggressive cross module optimisation is used (a use case that
* has not been exercised to any great extend) then it is feasible that the
* volatile qualifier will be needed for correct optimisation. It is expected
* that a compiler removing essential code because, without the volatile
* qualifier on the list structure members and with aggressive cross module
* optimisation, the compiler deemed the code unnecessary will result in
* complete and obvious failure of the scheduler. If this is ever experienced
* then the volatile qualifier can be inserted in the relevant places within the
* list structures by simply defining configLIST_VOLATILE to volatile in
* FreeRTOSConfig.h (as per the example at the bottom of this comment block).
* If configLIST_VOLATILE is not defined then the preprocessor directives below
* will simply #define configLIST_VOLATILE away completely.
*
* To use volatile list structure members then add the following line to
* FreeRTOSConfig.h (without the quotes):
* "#define configLIST_VOLATILE volatile"
*/
#ifndef configLIST_VOLATILE
#define configLIST_VOLATILE
#endif /* configSUPPORT_CROSS_MODULE_OPTIMISATION */
#ifdef __cplusplus
extern "C" {
#endif
/* Macros that can be used to place known values within the list structures,
then check that the known values do not get corrupted during the execution of
the application. These may catch the list data structures being overwritten in
memory. They will not catch data errors caused by incorrect configuration or
use of FreeRTOS.*/
#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 )
/* Define the macros to do nothing. */
#define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE
#define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE
#define listFIRST_LIST_INTEGRITY_CHECK_VALUE
#define listSECOND_LIST_INTEGRITY_CHECK_VALUE
#define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem )
#define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem )
#define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList )
#define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList )
#define listTEST_LIST_ITEM_INTEGRITY( pxItem )
#define listTEST_LIST_INTEGRITY( pxList )
#else
/* Define macros that add new members into the list structures. */
#define listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue1;
#define listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE TickType_t xListItemIntegrityValue2;
#define listFIRST_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue1;
#define listSECOND_LIST_INTEGRITY_CHECK_VALUE TickType_t xListIntegrityValue2;
/* Define macros that set the new structure members to known values. */
#define listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE
#define listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE
#define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE
#define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE
/* Define macros that will assert if one of the structure members does not
contain its expected value. */
#define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) )
#define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) )
#endif /* configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES */
/*
* Definition of the only type of object that a list can contain.
*/
struct xLIST_ITEM {
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */
struct xLIST_ITEM *configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */
struct xLIST_ITEM *configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */
void *pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */
void *configLIST_VOLATILE pvContainer; /*< Pointer to the list in which this list item is placed (if any). */
listSECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
};
typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */
struct xMINI_LIST_ITEM {
listFIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
configLIST_VOLATILE TickType_t xItemValue;
struct xLIST_ITEM *configLIST_VOLATILE pxNext;
struct xLIST_ITEM *configLIST_VOLATILE pxPrevious;
};
typedef struct xMINI_LIST_ITEM MiniListItem_t;
/*
* Definition of the type of queue used by the scheduler.
*/
typedef struct xLIST {
listFIRST_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
configLIST_VOLATILE UBaseType_t uxNumberOfItems;
ListItem_t *configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */
MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */
listSECOND_LIST_INTEGRITY_CHECK_VALUE /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */
} List_t;
/*
* Access macro to set the owner of a list item. The owner of a list item
* is the object (usually a TCB) that contains the list item.
*
* \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER
* \ingroup LinkedList
*/
#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( ( pxListItem )->pvOwner = ( void * ) ( pxOwner ) )
/*
* Access macro to get the owner of a list item. The owner of a list item
* is the object (usually a TCB) that contains the list item.
*
* \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER
* \ingroup LinkedList
*/
#define listGET_LIST_ITEM_OWNER( pxListItem ) ( ( pxListItem )->pvOwner )
/*
* Access macro to set the value of the list item. In most cases the value is
* used to sort the list in descending order.
*
* \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE
* \ingroup LinkedList
*/
#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( ( pxListItem )->xItemValue = ( xValue ) )
/*
* Access macro to retrieve the value of the list item. The value can
* represent anything - for example the priority of a task, or the time at
* which a task should be unblocked.
*
* \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE
* \ingroup LinkedList
*/
#define listGET_LIST_ITEM_VALUE( pxListItem ) ( ( pxListItem )->xItemValue )
/*
* Access macro to retrieve the value of the list item at the head of a given
* list.
*
* \page listGET_LIST_ITEM_VALUE listGET_LIST_ITEM_VALUE
* \ingroup LinkedList
*/
#define listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext->xItemValue )
/*
* Return the list item at the head of the list.
*
* \page listGET_HEAD_ENTRY listGET_HEAD_ENTRY
* \ingroup LinkedList
*/
#define listGET_HEAD_ENTRY( pxList ) ( ( ( pxList )->xListEnd ).pxNext )
/*
* Return the list item at the head of the list.
*
* \page listGET_NEXT listGET_NEXT
* \ingroup LinkedList
*/
#define listGET_NEXT( pxListItem ) ( ( pxListItem )->pxNext )
/*
* Return the list item that marks the end of the list
*
* \page listGET_END_MARKER listGET_END_MARKER
* \ingroup LinkedList
*/
#define listGET_END_MARKER( pxList ) ( ( ListItem_t const * ) ( &( ( pxList )->xListEnd ) ) )
/*
* Access macro to determine if a list contains any items. The macro will
* only have the value true if the list is empty.
*
* \page listLIST_IS_EMPTY listLIST_IS_EMPTY
* \ingroup LinkedList
*/
#define listLIST_IS_EMPTY( pxList ) ( ( BaseType_t ) ( ( pxList )->uxNumberOfItems == ( UBaseType_t ) 0 ) )
/*
* Access macro to return the number of items in the list.
*/
#define listCURRENT_LIST_LENGTH( pxList ) ( ( pxList )->uxNumberOfItems )
/*
* Access function to obtain the owner of the next entry in a list.
*
* The list member pxIndex is used to walk through a list. Calling
* listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list
* and returns that entry's pxOwner parameter. Using multiple calls to this
* function it is therefore possible to move through every item contained in
* a list.
*
* The pxOwner parameter of a list item is a pointer to the object that owns
* the list item. In the scheduler this is normally a task control block.
* The pxOwner parameter effectively creates a two way link between the list
* item and its owner.
*
* @param pxTCB pxTCB is set to the address of the owner of the next list item.
* @param pxList The list from which the next item owner is to be returned.
*
* \page listGET_OWNER_OF_NEXT_ENTRY listGET_OWNER_OF_NEXT_ENTRY
* \ingroup LinkedList
*/
#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \
{ \
List_t * const pxConstList = ( pxList ); \
/* Increment the index to the next item and return the item, ensuring */ \
/* we don't return the marker used at the end of the list. */ \
( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \
if( ( void * ) ( pxConstList )->pxIndex == ( void * ) &( ( pxConstList )->xListEnd ) ) \
{ \
( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \
} \
( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \
}
/*
* Access function to obtain the owner of the first entry in a list. Lists
* are normally sorted in ascending item value order.
*
* This function returns the pxOwner member of the first item in the list.
* The pxOwner parameter of a list item is a pointer to the object that owns
* the list item. In the scheduler this is normally a task control block.
* The pxOwner parameter effectively creates a two way link between the list
* item and its owner.
*
* @param pxList The list from which the owner of the head item is to be
* returned.
*
* \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY
* \ingroup LinkedList
*/
#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( (&( ( pxList )->xListEnd ))->pxNext->pvOwner )
/*
* Check to see if a list item is within a list. The list item maintains a
* "container" pointer that points to the list it is in. All this macro does
* is check to see if the container and the list match.
*
* @param pxList The list we want to know if the list item is within.
* @param pxListItem The list item we want to know if is in the list.
* @return pdTRUE if the list item is in the list, otherwise pdFALSE.
*/
#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( BaseType_t ) ( ( pxListItem )->pvContainer == ( void * ) ( pxList ) ) )
/*
* Return the list a list item is contained within (referenced from).
*
* @param pxListItem The list item being queried.
* @return A pointer to the List_t object that references the pxListItem
*/
#define listLIST_ITEM_CONTAINER( pxListItem ) ( ( pxListItem )->pvContainer )
/*
* This provides a crude means of knowing if a list has been initialised, as
* pxList->xListEnd.xItemValue is set to portMAX_DELAY by the vListInitialise()
* function.
*/
#define listLIST_IS_INITIALISED( pxList ) ( ( pxList )->xListEnd.xItemValue == portMAX_DELAY )
/*
* Must be called before a list is used! This initialises all the members
* of the list structure and inserts the xListEnd item into the list as a
* marker to the back of the list.
*
* @param pxList Pointer to the list being initialised.
*
* \page vListInitialise vListInitialise
* \ingroup LinkedList
*/
void vListInitialise(List_t *const pxList) PRIVILEGED_FUNCTION;
/*
* Must be called before a list item is used. This sets the list container to
* null so the item does not think that it is already contained in a list.
*
* @param pxItem Pointer to the list item being initialised.
*
* \page vListInitialiseItem vListInitialiseItem
* \ingroup LinkedList
*/
void vListInitialiseItem(ListItem_t *const pxItem) PRIVILEGED_FUNCTION;
/*
* Insert a list item into a list. The item will be inserted into the list in
* a position determined by its item value (descending item value order).
*
* @param pxList The list into which the item is to be inserted.
*
* @param pxNewListItem The item that is to be placed in the list.
*
* \page vListInsert vListInsert
* \ingroup LinkedList
*/
void vListInsert(List_t *const pxList, ListItem_t *const pxNewListItem) PRIVILEGED_FUNCTION;
/*
* Insert a list item into a list. The item will be inserted in a position
* such that it will be the last item within the list returned by multiple
* calls to listGET_OWNER_OF_NEXT_ENTRY.
*
* The list member pxIndex is used to walk through a list. Calling
* listGET_OWNER_OF_NEXT_ENTRY increments pxIndex to the next item in the list.
* Placing an item in a list using vListInsertEnd effectively places the item
* in the list position pointed to by pxIndex. This means that every other
* item within the list will be returned by listGET_OWNER_OF_NEXT_ENTRY before
* the pxIndex parameter again points to the item being inserted.
*
* @param pxList The list into which the item is to be inserted.
*
* @param pxNewListItem The list item to be inserted into the list.
*
* \page vListInsertEnd vListInsertEnd
* \ingroup LinkedList
*/
void vListInsertEnd(List_t *const pxList, ListItem_t *const pxNewListItem) PRIVILEGED_FUNCTION;
/*
* Remove an item from a list. The list item has a pointer to the list that
* it is in, so only the list item need be passed into the function.
*
* @param uxListRemove The item to be removed. The item will remove itself from
* the list pointed to by it's pxContainer parameter.
*
* @return The number of items that remain in the list after the list item has
* been removed.
*
* \page uxListRemove uxListRemove
* \ingroup LinkedList
*/
UBaseType_t uxListRemove(ListItem_t *const pxItemToRemove) PRIVILEGED_FUNCTION;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,201 @@
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
#ifndef MPU_WRAPPERS_H
#define MPU_WRAPPERS_H
/* This file redefines API functions to be called through a wrapper macro, but
only for ports that are using the MPU. */
#ifdef portUSING_MPU_WRAPPERS
/* MPU_WRAPPERS_INCLUDED_FROM_API_FILE will be defined when this file is
included from queue.c or task.c to prevent it from having an effect within
those files. */
#ifndef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
/*
* Map standard (non MPU) API functions to equivalents that start
* "MPU_". This will cause the application code to call the MPU_
* version, which wraps the non-MPU version with privilege promoting
* then demoting code, so the kernel code always runs will full
* privileges.
*/
/* Map standard tasks.h API functions to the MPU equivalents. */
#define xTaskCreate MPU_xTaskCreate
#define xTaskCreateStatic MPU_xTaskCreateStatic
#define xTaskCreateRestricted MPU_xTaskCreateRestricted
#define vTaskAllocateMPURegions MPU_vTaskAllocateMPURegions
#define vTaskDelete MPU_vTaskDelete
#define vTaskDelay MPU_vTaskDelay
#define vTaskDelayUntil MPU_vTaskDelayUntil
#define xTaskAbortDelay MPU_xTaskAbortDelay
#define uxTaskPriorityGet MPU_uxTaskPriorityGet
#define eTaskGetState MPU_eTaskGetState
#define vTaskGetInfo MPU_vTaskGetInfo
#define vTaskPrioritySet MPU_vTaskPrioritySet
#define vTaskSuspend MPU_vTaskSuspend
#define vTaskResume MPU_vTaskResume
#define vTaskSuspendAll MPU_vTaskSuspendAll
#define xTaskResumeAll MPU_xTaskResumeAll
#define xTaskGetTickCount MPU_xTaskGetTickCount
#define uxTaskGetNumberOfTasks MPU_uxTaskGetNumberOfTasks
#define pcTaskGetName MPU_pcTaskGetName
#define xTaskGetHandle MPU_xTaskGetHandle
#define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark
#define vTaskSetApplicationTaskTag MPU_vTaskSetApplicationTaskTag
#define xTaskGetApplicationTaskTag MPU_xTaskGetApplicationTaskTag
#define vTaskSetThreadLocalStoragePointer MPU_vTaskSetThreadLocalStoragePointer
#define pvTaskGetThreadLocalStoragePointer MPU_pvTaskGetThreadLocalStoragePointer
#define xTaskCallApplicationTaskHook MPU_xTaskCallApplicationTaskHook
#define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle
#define uxTaskGetSystemState MPU_uxTaskGetSystemState
#define vTaskList MPU_vTaskList
#define vTaskGetRunTimeStats MPU_vTaskGetRunTimeStats
#define xTaskGenericNotify MPU_xTaskGenericNotify
#define xTaskNotifyWait MPU_xTaskNotifyWait
#define ulTaskNotifyTake MPU_ulTaskNotifyTake
#define xTaskNotifyStateClear MPU_xTaskNotifyStateClear
#define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle
#define vTaskSetTimeOutState MPU_vTaskSetTimeOutState
#define xTaskCheckForTimeOut MPU_xTaskCheckForTimeOut
#define xTaskGetSchedulerState MPU_xTaskGetSchedulerState
/* Map standard queue.h API functions to the MPU equivalents. */
#define xQueueGenericSend MPU_xQueueGenericSend
#define xQueueGenericReceive MPU_xQueueGenericReceive
#define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting
#define uxQueueSpacesAvailable MPU_uxQueueSpacesAvailable
#define vQueueDelete MPU_vQueueDelete
#define xQueueCreateMutex MPU_xQueueCreateMutex
#define xQueueCreateMutexStatic MPU_xQueueCreateMutexStatic
#define xQueueCreateCountingSemaphore MPU_xQueueCreateCountingSemaphore
#define xQueueCreateCountingSemaphoreStatic MPU_xQueueCreateCountingSemaphoreStatic
#define xQueueGetMutexHolder MPU_xQueueGetMutexHolder
#define xQueueTakeMutexRecursive MPU_xQueueTakeMutexRecursive
#define xQueueGiveMutexRecursive MPU_xQueueGiveMutexRecursive
#define xQueueGenericCreate MPU_xQueueGenericCreate
#define xQueueGenericCreateStatic MPU_xQueueGenericCreateStatic
#define xQueueCreateSet MPU_xQueueCreateSet
#define xQueueAddToSet MPU_xQueueAddToSet
#define xQueueRemoveFromSet MPU_xQueueRemoveFromSet
#define xQueueSelectFromSet MPU_xQueueSelectFromSet
#define xQueueGenericReset MPU_xQueueGenericReset
#if( configQUEUE_REGISTRY_SIZE > 0 )
#define vQueueAddToRegistry MPU_vQueueAddToRegistry
#define vQueueUnregisterQueue MPU_vQueueUnregisterQueue
#define pcQueueGetName MPU_pcQueueGetName
#endif
/* Map standard timer.h API functions to the MPU equivalents. */
#define xTimerCreate MPU_xTimerCreate
#define xTimerCreateStatic MPU_xTimerCreateStatic
#define pvTimerGetTimerID MPU_pvTimerGetTimerID
#define vTimerSetTimerID MPU_vTimerSetTimerID
#define xTimerIsTimerActive MPU_xTimerIsTimerActive
#define xTimerGetTimerDaemonTaskHandle MPU_xTimerGetTimerDaemonTaskHandle
#define xTimerPendFunctionCall MPU_xTimerPendFunctionCall
#define pcTimerGetName MPU_pcTimerGetName
#define xTimerGetPeriod MPU_xTimerGetPeriod
#define xTimerGetExpiryTime MPU_xTimerGetExpiryTime
#define xTimerGenericCommand MPU_xTimerGenericCommand
/* Map standard event_group.h API functions to the MPU equivalents. */
#define xEventGroupCreate MPU_xEventGroupCreate
#define xEventGroupCreateStatic MPU_xEventGroupCreateStatic
#define xEventGroupWaitBits MPU_xEventGroupWaitBits
#define xEventGroupClearBits MPU_xEventGroupClearBits
#define xEventGroupSetBits MPU_xEventGroupSetBits
#define xEventGroupSync MPU_xEventGroupSync
#define vEventGroupDelete MPU_vEventGroupDelete
/* Remove the privileged function macro. */
#define PRIVILEGED_FUNCTION
#else /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
/* Ensure API functions go in the privileged execution section. */
#define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions")))
#define PRIVILEGED_DATA __attribute__((section("privileged_data")))
#endif /* MPU_WRAPPERS_INCLUDED_FROM_API_FILE */
#else /* portUSING_MPU_WRAPPERS */
#define PRIVILEGED_FUNCTION
#define PRIVILEGED_DATA
#define portUSING_MPU_WRAPPERS 0
#endif /* portUSING_MPU_WRAPPERS */
#endif /* MPU_WRAPPERS_H */

View File

@ -0,0 +1,263 @@
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
#ifndef PORTMACRO_H
#define PORTMACRO_H
#include "asm/cpu.h"
#include <stdint.h>
/******************************************************************************
Defines
******************************************************************************/
/* Type definitions. */
#define portCHAR char
#define portFLOAT float
#define portDOUBLE double
#define portLONG long
#define portSHORT short
#define portSTACK_TYPE int
#define portBASE_TYPE long
#define portPOINTER_SIZE_TYPE size_t
typedef portSTACK_TYPE StackType_t;
typedef long BaseType_t;
typedef unsigned long UBaseType_t;
#if( configUSE_16_BIT_TICKS == 1 )
typedef uint16_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffff
#else
typedef uint32_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
/* 32/64-bit tick type on a 32/64-bit architecture, so reads of the tick
count do not need to be guarded with a critical section. */
#define portTICK_TYPE_IS_ATOMIC 1
#endif
/* Hardware specifics. */
#define portSTACK_GROWTH ( -1 )
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portINLINE __inline
#if defined( __x86_64__) || defined( _M_X64 )
#define portBYTE_ALIGNMENT 8
#else
#define portBYTE_ALIGNMENT 4
#endif
extern void vPortYield() ;
#define portYIELD() vPortYield()
#define OS_CPU_ID current_cpu_id()
extern int current_cpu_id() ;
#define OS_CPU_NUM CPU_CORE_NUM
/* Simulated interrupts return pdFALSE if no context switch should be performed,
or a non-zero number if a context switch should be performed. */
#define portYIELD_FROM_ISR( x ) return x
#define portEND_SWITCHING_ISR( x ) portYIELD_FROM_ISR( ( x ) )
void vPortCloseRunningThread(void *pvTaskToDelete, volatile BaseType_t *pxPendYield);
//void vPortDeleteThread( void *pvThreadToDelete );
#define portCLEAN_UP_TCB( pxTCB ) //vPortDeleteThread( pxTCB )
#define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) //vPortCloseRunningThread( ( pvTaskToDelete ), ( pxPendYield ) )
#define portDISABLE_INTERRUPTS() CPU_CRITICAL_ENTER()
#define portENABLE_INTERRUPTS() CPU_CRITICAL_EXIT()
/* Critical section handling. */
void vPortEnterCritical(void);
void vPortExitCritical(void);
//extern void * malloc(int ) ;
//extern void free(void *) ;
//#define pvPortMalloc malloc
//#define vPortFree free
/*
extern volatile int cpu_lock_cnt[];
extern volatile int irq_lock_cnt[];
#define __asm_csync() \
do { \
asm volatile("csync;"); \
asm volatile("csync;"); \
asm volatile("csync;"); \
asm volatile("csync;"); \
asm volatile("csync;"); \
} while (0)
static inline void local_irq_disable()
{
__builtin_pi32v2_cli();
irq_lock_cnt[current_cpu_id()]++;
}
static inline void local_irq_enable()
{
if (--irq_lock_cnt[current_cpu_id()] == 0) {
__builtin_pi32v2_sti();
}
}
#define CPU_CRITICAL_ENTER() \
do { \
local_irq_disable(); \
if(cpu_lock_cnt[current_cpu_id()]++ == 0) \
asm volatile("lockset;"); \
__asm_csync(); \
}while(0)
#define CPU_CRITICAL_EXIT() \
do { \
if (--cpu_lock_cnt[current_cpu_id()] == 0) \
asm volatile("lockclr;"); \
local_irq_enable();\
}while(0)
*/
#define portENTER_CRITICAL() CPU_CRITICAL_ENTER() // vPortEnterCritical()
#define portEXIT_CRITICAL() CPU_CRITICAL_EXIT() // vPortExitCritical()
#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
#endif
#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
extern __attribute__((always_inline)) uint32_t ucPortCountLeadingZeros(uint32_t ulBitmap);
/* Check the configuration. */
#if( configMAX_PRIORITIES > 32 )
#error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.
#endif
/* Store/clear the ready priorities in a bit map. */
#define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
#define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) \
do { \
( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) ); \
} while (0)
/*-----------------------------------------------------------*/
// uxTopPriority = __builtin_pi32v2_clz(uxReadyPriorities)
#ifdef __GNUC__
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - ucPortCountLeadingZeros( ( uxReadyPriorities ) ) )
#else
/* BitScanReverse returns the bit position of the most significant '1'
in the word. */
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) _BitScanReverse( ( DWORD * ) &( uxTopPriority ), ( uxReadyPriorities ) )
#endif /* __GNUC__ */
#endif /* taskRECORD_READY_PRIORITY */
#ifndef __GNUC__
__pragma(warning(disable: 4211)) /* Nonstandard extension used, as extern is only nonstandard to MSVC. */
#endif
/* Task function macros as described on the FreeRTOS.org WEB site. */
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
#define portINTERRUPT_YIELD ( 0UL )
#define portINTERRUPT_TICK ( 1UL )
/*
* Raise a simulated interrupt represented by the bit mask in ulInterruptMask.
* Each bit can be used to represent an individual interrupt - with the first
* two bits being used for the Yield and Tick interrupts respectively.
*/
void vPortGenerateSimulatedInterrupt(uint32_t ulInterruptNumber);
/*
* Install an interrupt handler to be called by the simulated interrupt handler
* thread. The interrupt number must be above any used by the kernel itself
* (at the time of writing the kernel was using interrupt numbers 0, 1, and 2
* as defined above). The number must also be lower than 32.
*
* Interrupt handler functions must return a non-zero value if executing the
* handler resulted in a task switch being required.
*/
void vPortSetInterruptHandler(uint32_t ulInterruptNumber, uint32_t (*pvHandler)(void));
/* Tickless idle/low power functionality. */
#ifndef portSUPPRESS_TICKS_AND_SLEEP
extern void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime);
#define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime )
#endif
#endif

View File

@ -0,0 +1,262 @@
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
#ifndef PORTMACRO_H
#define PORTMACRO_H
#include "asm/cpu.h"
#include <stdint.h>
/******************************************************************************
Defines
******************************************************************************/
/* Type definitions. */
#define portCHAR char
#define portFLOAT float
#define portDOUBLE double
#define portLONG long
#define portSHORT short
#define portSTACK_TYPE int
#define portBASE_TYPE long
#define portPOINTER_SIZE_TYPE size_t
typedef portSTACK_TYPE StackType_t;
typedef long BaseType_t;
typedef unsigned long UBaseType_t;
#if( configUSE_16_BIT_TICKS == 1 )
typedef uint16_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffff
#else
typedef uint32_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
/* 32/64-bit tick type on a 32/64-bit architecture, so reads of the tick
count do not need to be guarded with a critical section. */
#define portTICK_TYPE_IS_ATOMIC 1
#endif
/* Hardware specifics. */
#define portSTACK_GROWTH ( -1 )
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portINLINE __inline
#if defined( __x86_64__) || defined( _M_X64 )
#define portBYTE_ALIGNMENT 8
#else
#define portBYTE_ALIGNMENT 4
#endif
extern void vPortYield() ;
#define portYIELD() vPortYield()
#define OS_CPU_ID current_cpu_id()
extern int current_cpu_id() ;
#define OS_CPU_NUM CPU_CORE_NUM
/* Simulated interrupts return pdFALSE if no context switch should be performed,
or a non-zero number if a context switch should be performed. */
#define portYIELD_FROM_ISR( x ) return x
#define portEND_SWITCHING_ISR( x ) portYIELD_FROM_ISR( ( x ) )
void vPortCloseRunningThread(void *pvTaskToDelete, volatile BaseType_t *pxPendYield);
//void vPortDeleteThread( void *pvThreadToDelete );
#define portCLEAN_UP_TCB( pxTCB ) //vPortDeleteThread( pxTCB )
#define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) //vPortCloseRunningThread( ( pvTaskToDelete ), ( pxPendYield ) )
#define portDISABLE_INTERRUPTS() CPU_CRITICAL_ENTER()
#define portENABLE_INTERRUPTS() CPU_CRITICAL_EXIT()
/* Critical section handling. */
void vPortEnterCritical(void);
void vPortExitCritical(void);
//extern void * malloc(int ) ;
//extern void free(void *) ;
//#define pvPortMalloc malloc
//#define vPortFree free
/*
extern volatile int cpu_lock_cnt[];
extern volatile int irq_lock_cnt[];
#define __asm_csync() \
do { \
asm volatile("csync;"); \
asm volatile("csync;"); \
asm volatile("csync;"); \
asm volatile("csync;"); \
asm volatile("csync;"); \
} while (0)
static inline void local_irq_disable()
{
__builtin_pi32v2_cli();
irq_lock_cnt[current_cpu_id()]++;
}
static inline void local_irq_enable()
{
if (--irq_lock_cnt[current_cpu_id()] == 0) {
__builtin_pi32v2_sti();
}
}
#define CPU_CRITICAL_ENTER() \
do { \
local_irq_disable(); \
if(cpu_lock_cnt[current_cpu_id()]++ == 0) \
asm volatile("lockset;"); \
__asm_csync(); \
}while(0)
#define CPU_CRITICAL_EXIT() \
do { \
if (--cpu_lock_cnt[current_cpu_id()] == 0) \
asm volatile("lockclr;"); \
local_irq_enable();\
}while(0)
*/
#define portENTER_CRITICAL() CPU_CRITICAL_ENTER() // vPortEnterCritical()
#define portEXIT_CRITICAL() CPU_CRITICAL_EXIT() // vPortExitCritical()
#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
#endif
#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
/* Check the configuration. */
#if( configMAX_PRIORITIES > 32 )
#error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.
#endif
/* Store/clear the ready priorities in a bit map. */
#define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
#define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) \
do { \
( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) ); \
} while (0)
/*-----------------------------------------------------------*/
// uxTopPriority = __builtin_pi32v2_clz(uxReadyPriorities)
#ifdef __GNUC__
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) \
uxTopPriority = 31- __builtin_clz(uxReadyPriorities)
#else
/* BitScanReverse returns the bit position of the most significant '1'
in the word. */
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) _BitScanReverse( ( DWORD * ) &( uxTopPriority ), ( uxReadyPriorities ) )
#endif /* __GNUC__ */
#endif /* taskRECORD_READY_PRIORITY */
#ifndef __GNUC__
__pragma(warning(disable: 4211)) /* Nonstandard extension used, as extern is only nonstandard to MSVC. */
#endif
/* Task function macros as described on the FreeRTOS.org WEB site. */
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
#define portINTERRUPT_YIELD ( 0UL )
#define portINTERRUPT_TICK ( 1UL )
/*
* Raise a simulated interrupt represented by the bit mask in ulInterruptMask.
* Each bit can be used to represent an individual interrupt - with the first
* two bits being used for the Yield and Tick interrupts respectively.
*/
void vPortGenerateSimulatedInterrupt(uint32_t ulInterruptNumber);
/*
* Install an interrupt handler to be called by the simulated interrupt handler
* thread. The interrupt number must be above any used by the kernel itself
* (at the time of writing the kernel was using interrupt numbers 0, 1, and 2
* as defined above). The number must also be lower than 32.
*
* Interrupt handler functions must return a non-zero value if executing the
* handler resulted in a task switch being required.
*/
void vPortSetInterruptHandler(uint32_t ulInterruptNumber, uint32_t (*pvHandler)(void));
/* Tickless idle/low power functionality. */
#ifndef portSUPPRESS_TICKS_AND_SLEEP
extern void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime);
#define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime )
#endif
#endif

View File

@ -0,0 +1,206 @@
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
/*-----------------------------------------------------------
* Portable layer API. Each function must be defined for each port.
*----------------------------------------------------------*/
#ifndef PORTABLE_H
#define PORTABLE_H
/* Each FreeRTOS port has a unique portmacro.h header file. Originally a
pre-processor definition was used to ensure the pre-processor found the correct
portmacro.h file for the port being used. That scheme was deprecated in favour
of setting the compiler's include path such that it found the correct
portmacro.h file - removing the need for the constant and allowing the
portmacro.h file to be located anywhere in relation to the port being used.
Purely for reasons of backward compatibility the old method is still valid, but
to make it clear that new projects should not use it, support for the port
specific constants has been moved into the deprecated_definitions.h header
file. */
#include "deprecated_definitions.h"
/* If portENTER_CRITICAL is not defined then including deprecated_definitions.h
did not result in a portmacro.h header file being included - and it should be
included here. In this case the path to the correct portmacro.h header file
must be set in the compiler's include path. */
#ifndef portENTER_CRITICAL
#include "portmacro.h"
#endif
#if portBYTE_ALIGNMENT == 32
#define portBYTE_ALIGNMENT_MASK ( 0x001f )
#endif
#if portBYTE_ALIGNMENT == 16
#define portBYTE_ALIGNMENT_MASK ( 0x000f )
#endif
#if portBYTE_ALIGNMENT == 8
#define portBYTE_ALIGNMENT_MASK ( 0x0007 )
#endif
#if portBYTE_ALIGNMENT == 4
#define portBYTE_ALIGNMENT_MASK ( 0x0003 )
#endif
#if portBYTE_ALIGNMENT == 2
#define portBYTE_ALIGNMENT_MASK ( 0x0001 )
#endif
#if portBYTE_ALIGNMENT == 1
#define portBYTE_ALIGNMENT_MASK ( 0x0000 )
#endif
#ifndef portBYTE_ALIGNMENT_MASK
#error "Invalid portBYTE_ALIGNMENT definition"
#endif
#ifndef portNUM_CONFIGURABLE_REGIONS
#define portNUM_CONFIGURABLE_REGIONS 1
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include "mpu_wrappers.h"
/*
* Setup the stack of a new task so it is ready to be placed under the
* scheduler control. The registers have to be placed on the stack in
* the order that the port expects to find them.
*
*/
#if( portUSING_MPU_WRAPPERS == 1 )
StackType_t *pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters, BaseType_t xRunPrivileged) PRIVILEGED_FUNCTION;
#else
StackType_t *pxPortInitialiseStack(StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters) PRIVILEGED_FUNCTION;
#endif
/* Used by heap_5.c. */
typedef struct HeapRegion {
uint8_t *pucStartAddress;
size_t xSizeInBytes;
} HeapRegion_t;
/*
* Used to define multiple heap regions for use by heap_5.c. This function
* must be called before any calls to pvPortMalloc() - not creating a task,
* queue, semaphore, mutex, software timer, event group, etc. will result in
* pvPortMalloc being called.
*
* pxHeapRegions passes in an array of HeapRegion_t structures - each of which
* defines a region of memory that can be used as the heap. The array is
* terminated by a HeapRegions_t structure that has a size of 0. The region
* with the lowest start address must appear first in the array.
*/
void vPortDefineHeapRegions(const HeapRegion_t *const pxHeapRegions) PRIVILEGED_FUNCTION;
/*
* Map to the memory management routines required for the port.
*/
void *pvPortMalloc(size_t xSize) PRIVILEGED_FUNCTION;
void vPortFree(void *pv) PRIVILEGED_FUNCTION;
void vPortInitialiseBlocks(void) PRIVILEGED_FUNCTION;
// size_t xPortGetFreeHeapSize(void) PRIVILEGED_FUNCTION;
// size_t xPortGetMinimumEverFreeHeapSize(void) PRIVILEGED_FUNCTION;
/*
* Setup the hardware ready for the scheduler to take control. This generally
* sets up a tick interrupt and sets timers for the correct tick frequency.
*/
BaseType_t xPortStartScheduler(void) PRIVILEGED_FUNCTION;
/*
* Undo any hardware/ISR setup that was performed by xPortStartScheduler() so
* the hardware is left in its original condition after the scheduler stops
* executing.
*/
void vPortEndScheduler(void) PRIVILEGED_FUNCTION;
/*
* The structures and methods of manipulating the MPU are contained within the
* port layer.
*
* Fills the xMPUSettings structure with the memory region information
* contained in xRegions.
*/
#if( portUSING_MPU_WRAPPERS == 1 )
struct xMEMORY_REGION;
void vPortStoreTaskMPUSettings(xMPU_SETTINGS *xMPUSettings, const struct xMEMORY_REGION *const xRegions, StackType_t *pxBottomOfStack, uint32_t ulStackDepth) PRIVILEGED_FUNCTION;
#endif
#ifdef __cplusplus
}
#endif
#endif /* PORTABLE_H */

View File

@ -0,0 +1,161 @@
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
#ifndef PROJDEFS_H
#define PROJDEFS_H
/*
* Defines the prototype to which task functions must conform. Defined in this
* file to ensure the type is known before portable.h is included.
*/
typedef void (*TaskFunction_t)(void *);
/* Converts a time in milliseconds to a time in ticks. This macro can be
overridden by a macro of the same name defined in FreeRTOSConfig.h in case the
definition here is not suitable for your application. */
#ifndef pdMS_TO_TICKS
#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( TickType_t ) ( xTimeInMs ) * ( TickType_t ) configTICK_RATE_HZ ) / ( TickType_t ) 1000 ) )
#endif
#define pdFALSE ( ( BaseType_t ) 0 )
#define pdTRUE ( ( BaseType_t ) 1 )
#define pdPASS ( pdTRUE )
#define pdFAIL ( pdFALSE )
#define errQUEUE_EMPTY ( ( BaseType_t ) 0 )
#define errQUEUE_FULL ( ( BaseType_t ) 0 )
/* FreeRTOS error definitions. */
#define errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY ( -1 )
#define errQUEUE_BLOCKED ( -4 )
#define errQUEUE_YIELD ( -5 )
/* Macros used for basic data corruption checks. */
#ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES
#define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0
#endif
#if( configUSE_16_BIT_TICKS == 1 )
#define pdINTEGRITY_CHECK_VALUE 0x5a5a
#else
#define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL
#endif
/* The following errno values are used by FreeRTOS+ components, not FreeRTOS
itself. */
#define pdFREERTOS_ERRNO_NONE 0 /* No errors */
#define pdFREERTOS_ERRNO_ENOENT 2 /* No such file or directory */
#define pdFREERTOS_ERRNO_EINTR 4 /* Interrupted system call */
#define pdFREERTOS_ERRNO_EIO 5 /* I/O error */
#define pdFREERTOS_ERRNO_ENXIO 6 /* No such device or address */
#define pdFREERTOS_ERRNO_EBADF 9 /* Bad file number */
#define pdFREERTOS_ERRNO_EAGAIN 11 /* No more processes */
#define pdFREERTOS_ERRNO_EWOULDBLOCK 11 /* Operation would block */
#define pdFREERTOS_ERRNO_ENOMEM 12 /* Not enough memory */
#define pdFREERTOS_ERRNO_EACCES 13 /* Permission denied */
#define pdFREERTOS_ERRNO_EFAULT 14 /* Bad address */
#define pdFREERTOS_ERRNO_EBUSY 16 /* Mount device busy */
#define pdFREERTOS_ERRNO_EEXIST 17 /* File exists */
#define pdFREERTOS_ERRNO_EXDEV 18 /* Cross-device link */
#define pdFREERTOS_ERRNO_ENODEV 19 /* No such device */
#define pdFREERTOS_ERRNO_ENOTDIR 20 /* Not a directory */
#define pdFREERTOS_ERRNO_EISDIR 21 /* Is a directory */
#define pdFREERTOS_ERRNO_EINVAL 22 /* Invalid argument */
#define pdFREERTOS_ERRNO_ENOSPC 28 /* No space left on device */
#define pdFREERTOS_ERRNO_ESPIPE 29 /* Illegal seek */
#define pdFREERTOS_ERRNO_EROFS 30 /* Read only file system */
#define pdFREERTOS_ERRNO_EUNATCH 42 /* Protocol driver not attached */
#define pdFREERTOS_ERRNO_EBADE 50 /* Invalid exchange */
#define pdFREERTOS_ERRNO_EFTYPE 79 /* Inappropriate file type or format */
#define pdFREERTOS_ERRNO_ENMFILE 89 /* No more files */
#define pdFREERTOS_ERRNO_ENOTEMPTY 90 /* Directory not empty */
#define pdFREERTOS_ERRNO_ENAMETOOLONG 91 /* File or path name too long */
#define pdFREERTOS_ERRNO_EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
#define pdFREERTOS_ERRNO_ENOBUFS 105 /* No buffer space available */
#define pdFREERTOS_ERRNO_ENOPROTOOPT 109 /* Protocol not available */
#define pdFREERTOS_ERRNO_EADDRINUSE 112 /* Address already in use */
#define pdFREERTOS_ERRNO_ETIMEDOUT 116 /* Connection timed out */
#define pdFREERTOS_ERRNO_EINPROGRESS 119 /* Connection already in progress */
#define pdFREERTOS_ERRNO_EALREADY 120 /* Socket already connected */
#define pdFREERTOS_ERRNO_EADDRNOTAVAIL 125 /* Address not available */
#define pdFREERTOS_ERRNO_EISCONN 127 /* Socket is already connected */
#define pdFREERTOS_ERRNO_ENOTCONN 128 /* Socket is not connected */
#define pdFREERTOS_ERRNO_ENOMEDIUM 135 /* No medium inserted */
#define pdFREERTOS_ERRNO_EILSEQ 138 /* An invalid UTF-16 sequence was encountered. */
#define pdFREERTOS_ERRNO_ECANCELED 140 /* Operation canceled. */
/* The following endian values are used by FreeRTOS+ components, not FreeRTOS
itself. */
#define pdFREERTOS_LITTLE_ENDIAN 0
#define pdFREERTOS_BIG_ENDIAN 1
#endif /* PROJDEFS_H */

View File

@ -0,0 +1,262 @@
/*
FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
All rights reserved
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
***************************************************************************
>>! NOTE: The modification to the GPL is included to allow you to !<<
>>! distribute a combined work that includes FreeRTOS without being !<<
>>! obliged to provide the source code for proprietary components !<<
>>! outside of the FreeRTOS kernel. !<<
***************************************************************************
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. Full license text is available on the following
link: http://www.freertos.org/a00114.html
***************************************************************************
* *
* FreeRTOS provides completely free yet professionally developed, *
* robust, strictly quality controlled, supported, and cross *
* platform software that is more than just the market leader, it *
* is the industry's de facto standard. *
* *
* Help yourself get started quickly while simultaneously helping *
* to support the FreeRTOS project by purchasing a FreeRTOS *
* tutorial book, reference manual, or both: *
* http://www.FreeRTOS.org/Documentation *
* *
***************************************************************************
http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
the FAQ page "My application does not run, what could be wrong?". Have you
defined configASSERT()?
http://www.FreeRTOS.org/support - In return for receiving this top quality
embedded software for free we request you assist our global community by
participating in the support forum.
http://www.FreeRTOS.org/training - Investing in training allows your team to
be as productive as possible as early as possible. Now you can receive
FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
Ltd, and the world's leading authority on the world's leading RTOS.
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
including FreeRTOS+Trace - an indispensable productivity tool, a DOS
compatible FAT file system, and our tiny thread aware UDP/IP stack.
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
licenses offer ticketed support, indemnification and commercial middleware.
http://www.SafeRTOS.com - High Integrity Systems also provide a safety
engineered and independently SIL3 certified version for use in safety and
mission critical applications that require provable dependability.
1 tab == 4 spaces!
*/
#ifndef PORTMACRO_H
#define PORTMACRO_H
#include "asm/cpu.h"
#include <stdint.h>
/******************************************************************************
Defines
******************************************************************************/
/* Type definitions. */
#define portCHAR char
#define portFLOAT float
#define portDOUBLE double
#define portLONG long
#define portSHORT short
#define portSTACK_TYPE int
#define portBASE_TYPE long
#define portPOINTER_SIZE_TYPE size_t
typedef portSTACK_TYPE StackType_t;
typedef long BaseType_t;
typedef unsigned long UBaseType_t;
#if( configUSE_16_BIT_TICKS == 1 )
typedef uint16_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffff
#else
typedef uint32_t TickType_t;
#define portMAX_DELAY ( TickType_t ) 0xffffffffUL
/* 32/64-bit tick type on a 32/64-bit architecture, so reads of the tick
count do not need to be guarded with a critical section. */
#define portTICK_TYPE_IS_ATOMIC 1
#endif
/* Hardware specifics. */
#define portSTACK_GROWTH ( -1 )
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
#define portINLINE __inline
#if defined( __x86_64__) || defined( _M_X64 )
#define portBYTE_ALIGNMENT 8
#else
#define portBYTE_ALIGNMENT 4
#endif
extern void vPortYield() ;
#define portYIELD() vPortYield()
#define OS_CPU_ID current_cpu_id()
extern int current_cpu_id() ;
#define OS_CPU_NUM CPU_CORE_NUM
/* Simulated interrupts return pdFALSE if no context switch should be performed,
or a non-zero number if a context switch should be performed. */
#define portYIELD_FROM_ISR( x ) return x
#define portEND_SWITCHING_ISR( x ) portYIELD_FROM_ISR( ( x ) )
void vPortCloseRunningThread(void *pvTaskToDelete, volatile BaseType_t *pxPendYield);
//void vPortDeleteThread( void *pvThreadToDelete );
#define portCLEAN_UP_TCB( pxTCB ) //vPortDeleteThread( pxTCB )
#define portPRE_TASK_DELETE_HOOK( pvTaskToDelete, pxPendYield ) //vPortCloseRunningThread( ( pvTaskToDelete ), ( pxPendYield ) )
#define portDISABLE_INTERRUPTS() CPU_CRITICAL_ENTER()
#define portENABLE_INTERRUPTS() CPU_CRITICAL_EXIT()
/* Critical section handling. */
void vPortEnterCritical(void);
void vPortExitCritical(void);
//extern void * malloc(int ) ;
//extern void free(void *) ;
//#define pvPortMalloc malloc
//#define vPortFree free
/*
extern volatile int cpu_lock_cnt[];
extern volatile int irq_lock_cnt[];
#define __asm_csync() \
do { \
asm volatile("csync;"); \
asm volatile("csync;"); \
asm volatile("csync;"); \
asm volatile("csync;"); \
asm volatile("csync;"); \
} while (0)
static inline void local_irq_disable()
{
__builtin_pi32v2_cli();
irq_lock_cnt[current_cpu_id()]++;
}
static inline void local_irq_enable()
{
if (--irq_lock_cnt[current_cpu_id()] == 0) {
__builtin_pi32v2_sti();
}
}
#define CPU_CRITICAL_ENTER() \
do { \
local_irq_disable(); \
if(cpu_lock_cnt[current_cpu_id()]++ == 0) \
asm volatile("lockset;"); \
__asm_csync(); \
}while(0)
#define CPU_CRITICAL_EXIT() \
do { \
if (--cpu_lock_cnt[current_cpu_id()] == 0) \
asm volatile("lockclr;"); \
local_irq_enable();\
}while(0)
*/
#define portENTER_CRITICAL() CPU_CRITICAL_ENTER() // vPortEnterCritical()
#define portEXIT_CRITICAL() CPU_CRITICAL_EXIT() // vPortExitCritical()
#ifndef configUSE_PORT_OPTIMISED_TASK_SELECTION
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
#endif
#if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1
/* Check the configuration. */
#if( configMAX_PRIORITIES > 32 )
#error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32. It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.
#endif
/* Store/clear the ready priorities in a bit map. */
#define portRECORD_READY_PRIORITY( uxPriority, uxReadyPriorities ) ( uxReadyPriorities ) |= ( 1UL << ( uxPriority ) )
#define portRESET_READY_PRIORITY( uxPriority, uxReadyPriorities ) \
do { \
( uxReadyPriorities ) &= ~( 1UL << ( uxPriority ) ); \
} while (0)
/*-----------------------------------------------------------*/
// uxTopPriority = __builtin_pi32v2_clz(uxReadyPriorities)
#ifdef __GNUC__
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) \
uxTopPriority = 31- __builtin_clz(uxReadyPriorities)
#else
/* BitScanReverse returns the bit position of the most significant '1'
in the word. */
#define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) _BitScanReverse( ( DWORD * ) &( uxTopPriority ), ( uxReadyPriorities ) )
#endif /* __GNUC__ */
#endif /* taskRECORD_READY_PRIORITY */
#ifndef __GNUC__
__pragma(warning(disable: 4211)) /* Nonstandard extension used, as extern is only nonstandard to MSVC. */
#endif
/* Task function macros as described on the FreeRTOS.org WEB site. */
#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void * pvParameters )
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void * pvParameters )
#define portINTERRUPT_YIELD ( 0UL )
#define portINTERRUPT_TICK ( 1UL )
/*
* Raise a simulated interrupt represented by the bit mask in ulInterruptMask.
* Each bit can be used to represent an individual interrupt - with the first
* two bits being used for the Yield and Tick interrupts respectively.
*/
void vPortGenerateSimulatedInterrupt(uint32_t ulInterruptNumber);
/*
* Install an interrupt handler to be called by the simulated interrupt handler
* thread. The interrupt number must be above any used by the kernel itself
* (at the time of writing the kernel was using interrupt numbers 0, 1, and 2
* as defined above). The number must also be lower than 32.
*
* Interrupt handler functions must return a non-zero value if executing the
* handler resulted in a task switch being required.
*/
void vPortSetInterruptHandler(uint32_t ulInterruptNumber, uint32_t (*pvHandler)(void));
/* Tickless idle/low power functionality. */
#ifndef portSUPPRESS_TICKS_AND_SLEEP
// extern void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime);
// #define portSUPPRESS_TICKS_AND_SLEEP( xExpectedIdleTime ) vPortSuppressTicksAndSleep( xExpectedIdleTime )
#endif
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,442 @@
#ifndef OS_API_H
#define OS_API_H
#ifdef __cplusplus
extern "C"
{
#endif
#include "generic/typedef.h"
//#include "generic/list.h"
#include "os/os_cpu.h"
#include "os/os_error.h"
#include "os/os_type.h"
typedef void *TaskHandle_t;
#define Q_MSG 0x100000
#define Q_EVENT 0x200000
#define Q_CALLBACK 0x300000
#define Q_USER 0x400000
#define OS_DEL_NO_PEND 0u
#define OS_DEL_ALWAYS 1u
#define OS_TASK_DEL_REQ 0x01u
#define OS_TASK_DEL_RES 0x02u
#define OS_TASK_DEL_OK 0x03u
#define OS_TASK_SELF (char *)0x1
#define OS_TASK_FATHER (char *)0x2
/* --------------------------------------------------------------------------*/
/**
* @brief reserved
*/
/* ----------------------------------------------------------------------------*/
void os_init(void);
/* --------------------------------------------------------------------------*/
/**
* @brief reserved
*/
/* ----------------------------------------------------------------------------*/
void os_start(void);
/* --------------------------------------------------------------------------*/
/**
* @brief reserved
*/
/* ----------------------------------------------------------------------------*/
void os_init_tick(int);
/* --------------------------------------------------------------------------*/
/**
* @brief 创建任务
*
* @param task 任务回调函数
* @param p_arg 传递给任务回调函数的参数
* @param prio 任务的优先级
* @param stksize 任务的堆栈大小, 单位(u32)
* @param qsize 任务的queue大小单位(byte)
* @param name 任务名 (名字长度不能超过configMAX_TASK_NAME_LEN字节)
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_task_create(void (*task)(void *p_arg),
void *p_arg,
u8 prio,
u32 stksize,
int qsize,
const char *name);
int os_task_create_affinity_core(void (*task)(void *p_arg),
void *p_arg,
u8 prio,
u32 stksize,
int qsize,
const char *name,
u8 core);
/* --------------------------------------------------------------------------*/
/**
* @brief 获取当前任务名
*
* @return 当前任务名
*/
/* ----------------------------------------------------------------------------*/
const char *os_current_task();
/* --------------------------------------------------------------------------*/
/**
* @brief 删除任务
*
* @param name 任务名
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_task_del_req(const char *name);
/* --------------------------------------------------------------------------*/
/**
* @brief 响应任务删除请求,标记资源已经释放,可以删除当前任
*
* @param name 任务名任务自己可以用OS_TASK_SELF
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_task_del_res(const char *name);
/* --------------------------------------------------------------------------*/
/**
* @brief 删除任务
*
* @param name 任务名
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_task_del(const char *name);
/* --------------------------------------------------------------------------*/
/**
* @brief 延时。中断函数或者关闭系统总中断的情况下不能调用此函数
*
* @param time_tick 延时时间
*/
/* ----------------------------------------------------------------------------*/
void os_time_dly(int time_tick);
/* --------------------------------------------------------------------------*/
/**
* @brief 发送Q_USER类型taskq
*
* @param name 任务名
* @param argc 后面传入的参数的个数。发送的最大参数个数限制为8个int类型
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_post(const char *name, int argc, ...);
/* --------------------------------------------------------------------------*/
/**
* @brief 非阻塞方式查询taskq
*
* @param argc 最大可获取的queue长度单位(int)
* @param argv 存放queue的buf
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_accept(int argc, int *argv);
/* --------------------------------------------------------------------------*/
/**
* @brief 阻塞方式获取taskq
*
* @param fmt 保留传NULL
* @param argv 存放queue的buf
* @param argc 最大可获取的queue长度单位(int)
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_pend(const char *fmt, int *argv, int argc);
// int os_task_pend(const char *fmt, int *argv, int argc);
// int __os_taskq_pend(int *argv, int argc, int tick);
/* --------------------------------------------------------------------------*/
/**
* @brief 发送指定类型的taskq
*
* @param name 任务名
* @param type queue类型
* @param argc 后面传入的参数的个数
* @param argv
*
* @return 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_post_type(const char *name, int type, int argc, int *argv);
/* --------------------------------------------------------------------------*/
/**
* @brief 发送Q_MSG类型的taskq
*
* @param name 任务名
* @param argc 后面参数的个数
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_post_msg(const char *name, int argc, ...);
/* --------------------------------------------------------------------------*/
/**
* @brief 发送Q_EVENT类型的taskq
*
* @param name 任务名
* @param argc 后面参数的个数
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_post_event(const char *name, int argc, ...);
/* --------------------------------------------------------------------------*/
/**
* @brief 删除指定类型的taskq
*
* @param name 任务名
* @param type taskq的类型
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_del_type(const char *name, int type);
/* --------------------------------------------------------------------------*/
/**
* @brief 清除所有taskq
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_taskq_flush(void);
/* --------------------------------------------------------------------------*/
/**
* @brief 创建信号量
*
* @param sem 信号量
* @param int 初始计数值
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_sem_create(OS_SEM *, int);
/* --------------------------------------------------------------------------*/
/**
* @brief 非阻塞方式查询信号量
*
* @param sem 信号量
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_sem_accept(OS_SEM *);
/* --------------------------------------------------------------------------*/
/**
* @brief 阻塞方式获取信号量
*
* @param sem 信号量
* @param timeout 等待时长0表示一直等待
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_sem_pend(OS_SEM *, int timeout);
/* --------------------------------------------------------------------------*/
/**
* @brief 发送信号量
*
* @param sem 信号量
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_sem_post(OS_SEM *);
/* --------------------------------------------------------------------------*/
/**
* @brief 信号量删除
*
* @param sem 信号量
* @param block 保留
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_sem_del(OS_SEM *, int block);
/* --------------------------------------------------------------------------*/
/**
* @brief 信号量设置
*
* @param sem 信号量
* @param cnt 计数值
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_sem_set(OS_SEM *, u16 cnt);
/* --------------------------------------------------------------------------*/
/**
* @brief 信号量类型是否queueQUEUE_TYPE_COUNTING_SEMAPHORE
*
* @param true:信号量匹配, fail:信号量不匹配
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_sem_valid(OS_SEM *);
/* --------------------------------------------------------------------------*/
/**
* @brief 判断信号量是否可用
*
* @param sem 信号量
*
* @reutrn 可用数量
*/
/* ----------------------------------------------------------------------------*/
int os_sem_query(OS_SEM *);
/* --------------------------------------------------------------------------*/
/**
* @brief 创建互斥量
*
* @param mutex 互斥量
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_mutex_create(OS_MUTEX *);
/* --------------------------------------------------------------------------*/
/**
* @brief 非阻塞方式查询互斥量
*
* @param mutex:互斥量
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_mutex_accept(OS_MUTEX *);
/* --------------------------------------------------------------------------*/
/**
* @brief 阻塞方式查询互斥量
*
* @param mutex 互斥量
* @param timeout 等待时间0表示一直等待
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_mutex_pend(OS_MUTEX *, int timeout);
/* --------------------------------------------------------------------------*/
/**
* @brief 发送斥量
*
* @param mutex 互斥量
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_mutex_post(OS_MUTEX *);
/* --------------------------------------------------------------------------*/
/**
* @brief 删除斥量
*
* @param mutex 互斥量
* @param block 保留
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_mutex_del(OS_MUTEX *, int block);
/* --------------------------------------------------------------------------*/
/**
* @brief 互斥量类型是否queueQUEUE_TYPE_MUTEX
*
* @param true:互斥量匹配, fail:互斥量不匹配
*
* @reutrn 错误码
*/
/* ----------------------------------------------------------------------------*/
int os_mutex_valid(OS_MUTEX *);
/*struct os_msg *os_message_create(int size);
int os_message_receive(struct os_msg **msg, int block_time);
int os_message_send(const char *task_name, struct os_msg *msg, int msgflg);
int os_message_delete(struct os_msg *msg);*/
int os_q_create(OS_QUEUE *pevent, /*void **start, */QS size);
int os_q_del(OS_QUEUE *pevent, u8 opt);
int os_q_flush(OS_QUEUE *pevent);
int os_q_pend(OS_QUEUE *pevent, int timeout, void *msg);
int os_q_post(OS_QUEUE *pevent, void *msg);
int os_q_query(OS_QUEUE *pevent);
int os_q_valid(OS_QUEUE *pevent);
int task_queue_post_event(const char *name, void *data, int len);
void *os_task_get_handle(const char *name);
void os_suspend_other_core(void);
void os_resume_other_core(void);
void os_system_info_output(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,135 @@
/***********************************Jieli tech************************************************
File : os_cfg.h
By : Juntham
date : 2014-07-03 09:09
********************************************************************************************/
#ifndef OS_CFG_H
#define OS_CFG_H
#include "os/os_cpu.h"
#define OS_TIME_SLICE_EN 1
#define OS_PRIORITY_INVERSION 1 /*是否处理优先级翻转*/
/* ---------------------- MISCELLANEOUS ----------------------- */
#define OS_ARG_CHK_EN 0 /* Enable (1) or Disable (0) argument checking */
#define OS_CPU_HOOKS_EN 1 /* hooks are found in the processor port files */
#if OS_TIME_SLICE_EN > 0
#define OS_LOWEST_PRIO (0) /* Defines the lowest priority that can be assigned ... */
#else
#define OS_LOWEST_PRIO (0+OS_CPU_CORE-1)/* Defines the lowest priority that can be assigned */
#endif
#define OS_IDLE_PRIO (OS_LOWEST_PRIO) /* IDLE task priority */
#define OS_MAX_TASKS 31 /* Max. number of tasks in your application, MUST be >= 2 */
#define OS_SCHED_LOCK_EN 1 /* Include code for OSSchedLock() and OSSchedUnlock() */
#define OS_TICKS_PER_SEC 100 /* Set the number of ticks in one second */
#define OS_PARENT_TCB 1 /* 是否记录父任务的TCB */
#define OS_CHILD_TCB 0 /* 是否记录子任务的TCB */
/* ----------------------TASK MESSAGE QUEUES ---------------------- */
#define OS_TASKQ_EN 1 /* Enable (1) or Disable (0) code generation for QUEUES */
#define OS_TASKQ_ACCEPT_EN 1 /* Include code for OSTaskQAccept() */
#define OS_TASKQ_PEND_EN 1 /* Include code for OSTaskQAccept() */
#define OS_TASKQ_FLUSH_EN 1 /* Include code for OSTaskQFlush() */
#define OS_TASKQ_POST_EN 1 /* Include code for OSTaskQPost() */
#define OS_TASKQ_POST_FRONT_EN 1 /* Include code for OSTaskQPostFront() */
#define OS_TASKQ_QUERY_EN 1 /* Include code for OSTaskQQuery() */
/* ---------------- MUTUAL EXCLUSION SEMAPHORES --------------- */
#define OS_MUTEX_EN 1 /* Enable (1) or Disable (0) code generation for MUTEX */
#define OS_MUTEX_ACCEPT_EN 1 /* Include code for OSMutexAccept() */
#define OS_MUTEX_DEL_EN 1 /* Include code for OSMutexDel() */
#define OS_MUTEX_QUERY_EN 0 /* Include code for OSMutexQuery() */
/* ------------------------ SEMAPHORES ------------------------ */
#define OS_SEM_EN 1 /* Enable (1) or Disable (0) code generation for SEMAPHORES */
#define OS_SEM_ACCEPT_EN 1 /* Include code for OSSemAccept() */
#define OS_SEM_DEL_EN 1 /* Include code for OSSemDel() */
#define OS_SEM_QUERY_EN 1 /* Include code for OSSemQuery() */
#define OS_SEM_SET_EN 1 /* Include code for OSSemSet() */
/* ---------------------- MESSAGE QUEUES ---------------------- */
#define OS_Q_EN 1 /* Enable (1) or Disable (0) code generation for QUEUES */
#define OS_Q_ACCEPT_EN 1 /* Include code for OSQAccept() */
#define OS_Q_DEL_EN 1 /* Include code for OSQDel() */
#define OS_Q_FLUSH_EN 1 /* Include code for OSQFlush() */
#define OS_Q_POST_EN 1 /* Include code for OSQPost() */
#define OS_Q_POST_FRONT_EN 1 /* Include code for OSQPostFront() */
#define OS_Q_POST_OPT_EN 1 /* Include code for OSQPostOpt() */
#define OS_Q_QUERY_EN 1 /* Include code for OSQQuery() */
/* ----------------------- EVENT FLAGS ------------------------ */
#define OS_FLAG_EN 0 /* Enable (1) or Disable (0) code generation for EVENT FLAGS */
#define OS_MAX_FLAGS 1 /* Max. number of Event Flag Groups in your application */
#define OS_FLAG_WAIT_CLR_EN 1 /* Include code for Wait on Clear EVENT FLAGS */
#define OS_FLAG_ACCEPT_EN 1 /* Include code for OSFlagAccept() */
#define OS_FLAG_DEL_EN 1 /* Include code for OSFlagDel() */
#define OS_FLAG_NAME_SIZE 0//32 /* Determine the size of the name of an event flag group */
#define OS_FLAG_QUERY_EN 1 /* Include code for OSFlagQuery() */
#define OS_FLAGS_NBITS 32 /* Size in #bits of OS_FLAGS data type (8, 16 or 32) */
/* --------------------- TASK MANAGEMENT ---------------------- */
#define OS_TASK_CHANGE_PRIO_EN 1 /* Include code for OSTaskChangePrio() */
#define OS_TASK_CREATE_EN 1 /* Include code for OSTaskCreate() */
#define OS_TASK_DEL_EN 1 /* Include code for OSTaskDel() */
#define OS_TASK_QUERY_EN 0 /* Include code for OSTaskQuery() */
#define OS_TASK_SUSPEND_EN 1 /* Include code for OSTaskSuspend() and OSTaskResume() */
#define OS_TASK_SW_HOOK_EN 0 /* Include code for OSTaskSwHook() */
#define OS_TASK_STK_CHK 0
/* --------------------- TIME MANAGEMENT ---------------------- */
#define OS_TIME_DLY_HMSM_EN 0 /* Include code for OSTimeDlyHMSM() */
#define OS_TIME_DLY_RESUME_EN 1 /* Include code for OSTimeDlyResume() */
#define OS_TIME_GET_SET_EN 1 /* Include code for OSTimeGet() and OSTimeSet() */
#define OS_TIME_TICK_HOOK_EN 0 /* Include code for OSTimeTickHook() */
#define OS_EVENT_EN ((OS_Q_EN > 0) || (OS_SEM_EN > 0) || (OS_MUTEX_EN > 0))
//for make
#define portMAX_DELAY 0
#ifndef tskIDLE_PRIORITY
#define tskIDLE_PRIORITY 0
#endif /* #ifndef tskIDLE_PRIORITY */
#ifndef configMAX_PRIORITIES
#define configMAX_PRIORITIES 8
#endif /* #ifndef configMAX_PRIORITIES */
#ifndef configSUPPORT_DYNAMIC_ALLOCATION
/* Defaults to 1 for backward compatibility. */
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#endif
#ifndef OS_CPU_NUM
#define OS_CPU_NUM CPU_CORE_NUM
#endif /* #ifndef OS_CPU_NUM */
#ifndef OS_MBOX_EN
#define OS_MBOX_EN 0
#endif
#ifndef OS_MEM_EN
#define OS_MEM_EN 0
#endif
#ifndef configAPPLICATION_ALLOCATED_HEAP
#define configAPPLICATION_ALLOCATED_HEAP 0
#endif
#ifndef configUSE_MALLOC_FAILED_HOOK
#define configUSE_MALLOC_FAILED_HOOK 0
#endif
#endif

View File

@ -0,0 +1,117 @@
/***********************************Jieli tech************************************************
File : os_cpu.h
By : Juntham
date : 2014-07-03 09:06
********************************************************************************************/
#ifndef _OS_CPU_H
#define _OS_CPU_H
#include "asm/cpu.h"
#include "jiffies.h"
#ifndef __ASSEMBLY__
typedef unsigned short QS;
typedef unsigned int OS_STK; /* Each stack entry is 32-bit wide*/
typedef unsigned int OS_CPU_SR; /* Unsigned 32 bit quantity */
typedef unsigned int OS_CPU_DATA; /* Unsigned 32 bit quantity */
#endif
#define OS_CPU_EXT extern
#define OS_CPU_CORE CPU_CORE_NUM
#define OS_CPU_ID current_cpu_id()
#define OS_STK_GROWTH 1 /* Stack grows from HIGH to LOW memory*/
#define OS_CPU_MMU 0
#define OS_CPU_VIRTUAL_MEM 1 //临时定义区别于OS_CPU_MMU
#ifndef OS_CORE_AFFINITY_ENABLE
#define OS_CORE_AFFINITY_ENABLE 0
#endif
#define OS_TASK_CLR(a) CPU_TASK_CLR(a)
#define OS_TASK_SW(a) CPU_TASK_SW(a) /* 任务级任务切换函数*/
#define OS_INT_NESTING CPU_INT_NESTING
#define CPU_SR_ALLOC()
#define OS_SR_ALLOC()
#define OS_ENTER_CRITICAL() \
CPU_CRITICAL_ENTER(); \
#define OS_EXIT_CRITICAL() \
CPU_CRITICAL_EXIT()
#ifndef __ASSEMBLY__
/*#include "system/spinlock.h"
extern spinlock_t os_lock;
#define OS_ENTER_CRITICAL() \
spin_lock(&os_lock)
#define OS_EXIT_CRITICAL() \
spin_unlock(&os_lock)*/
void OSCtxSw(void);
extern void EnableOtherCpu(void) ;
#define os_ctx_sw OSCtxSw
void OSInitTick(u32 hz);
void InstallOSISR(void);
void os_task_dead(const char *task_name);
//=======================================================//
// 系统进临界区多核同步类型 //
//=======================================================//
enum CPU_SUSPEND_TYPE {
CPU_SUSPEND_TYPE_NONE = 0,
CPU_SUSPEND_TYPE_SFC = 0x55, //操作Flash
CPU_SUSPEND_TYPE_PDOWN, //系统进低功耗Pdown
CPU_SUSPEND_TYPE_POFF, //系统进低功耗Pdown
CPU_SUSPEND_TYPE_SOFF,
};
/* ---------------------------------------------------------------------------- */
/**
* @brief 系统进入临界区用于多核同步
*/
/* ---------------------------------------------------------------------------- */
void cpu_suspend_other_core(enum CPU_SUSPEND_TYPE type);
/* ---------------------------------------------------------------------------- */
/**
* @brief 系统退出临界区用于多核同步
*/
/* ---------------------------------------------------------------------------- */
void cpu_resume_other_core(enum CPU_SUSPEND_TYPE type);
#endif
/*
*********************************************************************************************************
* DATA TYPES
* (Compiler Specific)
*********************************************************************************************************
*/
#define OS_CRITICAL_METHOD 3
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
//#define CPU_SR_ALLOC() OS_CPU_SR cpu_sr
#endif
#endif /*_OS_CPU_H */

View File

@ -0,0 +1,79 @@
#ifndef __OS_ERROR_H__
#define __OS_ERROR_H__
#define OS_ERR_NONE 0
enum {
OS_NO_ERR = 0,
OS_TRUE,
OS_ERR_EVENT_TYPE,
OS_ERR_PEND_ISR,
OS_ERR_POST_NULL_PTR,
OS_ERR_PEVENT_NULL,
OS_ERR_POST_ISR,
OS_ERR_QUERY_ISR,
OS_ERR_INVALID_OPT,
OS_ERR_TASK_WAITING,
OS_ERR_PDATA_NULL,
OS_TIMEOUT,
OS_TIMER,
OS_TASKQ,
OS_TASK_NOT_EXIST,
OS_ERR_EVENT_NAME_TOO_LONG,
OS_ERR_FLAG_NAME_TOO_LONG,
OS_ERR_TASK_NAME_TOO_LONG,
OS_ERR_PNAME_NULL,
OS_ERR_TASK_CREATE_ISR,
OS_MBOX_FULL,
OS_Q_FULL,
OS_Q_EMPTY,
OS_Q_ERR,
OS_ERR_NO_QBUF,
OS_PRIO_EXIST,
OS_PRIO_ERR,
OS_PRIO_INVALID,
OS_SEM_OVF,
OS_TASK_DEL_ERR,
OS_TASK_DEL_IDLE,
OS_TASK_DEL_ISR,
OS_NO_MORE_TCB,
OS_TIME_NOT_DLY,
OS_TIME_INVALID_MINUTES,
OS_TIME_INVALID_SECONDS,
OS_TIME_INVALID_MILLI,
OS_TIME_ZERO_DLY,
OS_TASK_SUSPEND_PRIO,
OS_TASK_SUSPEND_IDLE,
OS_TASK_RESUME_PRIO,
OS_TASK_NOT_SUSPENDED,
OS_MEM_INVALID_PART,
OS_MEM_INVALID_BLKS,
OS_MEM_INVALID_SIZE,
OS_MEM_NO_FREE_BLKS,
OS_MEM_FULL,
OS_MEM_INVALID_PBLK,
OS_MEM_INVALID_PMEM,
OS_MEM_INVALID_PDATA,
OS_MEM_INVALID_ADDR,
OS_MEM_NAME_TOO_LONG,
OS_ERR_MEM_NO_MEM,
OS_ERR_NOT_MUTEX_OWNER,
OS_TASK_OPT_ERR,
OS_ERR_DEL_ISR,
OS_ERR_CREATE_ISR,
OS_FLAG_INVALID_PGRP,
OS_FLAG_ERR_WAIT_TYPE,
OS_FLAG_ERR_NOT_RDY,
OS_FLAG_INVALID_OPT,
OS_FLAG_GRP_DEPLETED,
OS_ERR_PIP_LOWER,
OS_ERR_MSG_POOL_EMPTY,
OS_ERR_MSG_POOL_NULL_PTR,
OS_ERR_MSG_POOL_FULL,
};
#endif

View File

@ -0,0 +1,35 @@
#ifndef __OS_TYPE_H
#define __OS_TYPE_H
#define OS_TICKS_PER_SEC 100
#if defined CONFIG_UCOS_ENABLE
typedef struct {
unsigned char OSEventType;
int aa;
void *bb;
unsigned char value;
unsigned char prio;
unsigned short cc;
} OS_SEM, OS_MUTEX, OS_QUEUE;
#include <os/ucos_ii.h>
#elif defined CONFIG_FREE_RTOS_ENABLE
#include "FreeRTOS/FreeRTOS.h"
#include "FreeRTOS/semphr.h"
#include "FreeRTOS/task.h"
typedef StaticSemaphore_t OS_SEM, OS_MUTEX;
typedef StaticQueue_t OS_QUEUE;
#else
#error "no_os_defined"
#endif
#endif

View File

@ -0,0 +1,806 @@
/***********************************Jieli tech************************************************
File : ucos_ii.h
By : Juntham
date : 2014-07-03 09:09
********************************************************************************************/
#ifndef OS_uCOS_II_H
#define OS_uCOS_II_H
#include "generic/typedef.h"
#include "os/os_cpu.h"
#include "os/os_cfg.h"
#include "os/os_api.h"
/*
*********************************************************************************************************
* INCLUDE HEADER FILES
*********************************************************************************************************
*/
#ifdef __cplusplus
extern "C"
{
#endif
// #define uCOS_ENTER_CRITICAL() CPU_CRITICAL_ENTER()
// #define uCOS_EXIT_CRITICAL() CPU_CRITICAL_EXIT()
void uCOS_ENTER_CRITICAL(void);
void uCOS_EXIT_CRITICAL(void);
#define OS_VERSION 100u /* Version */
#define OS_STAT_RDY 0x00u /* Ready to run */
#define OS_STAT_SEM 0x01u /* Pending on semaphore */
#define OS_STAT_Q 0x02u /* Pending on queue */
#define OS_STAT_SUSPEND 0x04u /* Task is suspended */
#define OS_STAT_MUTEX 0x08u /* Pending on mutual exclusion semaphore */
#define OS_STAT_TASK_Q 0x10u /* Pending on task Q */
#define OS_STAT_DELAY 0x20u /* Task on delay */
#define OS_STAT_FLAG 0x40u /* Pending on event flag group */
#define OS_STAT_PEND_ANY (OS_STAT_SEM | OS_STAT_Q | OS_STAT_MUTEX | OS_STAT_TASK_Q)
/*
*********************************************************************************************************
* OS_EVENT types
*********************************************************************************************************
*/
#define OS_EVENT_TYPE_UNUSED 0u
#define OS_EVENT_TYPE_Q 1u
#define OS_EVENT_TYPE_SEM 2u
#define OS_EVENT_TYPE_MUTEX 3u
#define OS_EVENT_TYPE_FLAG 5u
/*
*********************************************************************************************************
* OS???PostOpt() OPTIONS
*
* These #defines are used to establish the options for OSMboxPostOpt() and OSQPostOpt().
*********************************************************************************************************
*/
#define OS_POST_OPT_NONE 0x00u /* NO option selected */
#define OS_POST_OPT_BROADCAST 0x01u /* Broadcast message to ALL tasks waiting */
#define OS_POST_OPT_FRONT 0x02u /* Post to highest priority task waiting */
/*
*********************************************************************************************************
* MISCELLANEOUS
*********************************************************************************************************
*/
#ifdef OS_GLOBALS
#define OS_EXT
#else
#define OS_EXT extern
#endif
/*
*********************************************************************************************************
* EVENT CONTROL BLOCK
*********************************************************************************************************
*/
#if OS_EVENT_EN
struct event_cnt {
u16 cnt;
};
struct event_mutex {
u8 value;
u8 prio;
u16 OwnerNestingCtr;
};
struct os_tcb;
typedef struct os_event {
u8 OSEventType; /* Type of event control block (see OS_EVENT_TYPE_xxxx) */
#if OS_TIME_SLICE_EN > 0
struct os_tcb *OSTCBList; /* TCB List */
#else
OS_CPU_DATA OSTCBList;
#endif
void *OSEventPtr; /* Pointer to message or queue structure */
union {
struct event_cnt OSEvent;
struct event_mutex OSMutex;
};
} OS_EVENT;
/*
*********************************************************************************************************
* EVENT FLAGS CONTROL BLOCK
*********************************************************************************************************
*/
#if (OS_FLAG_EN > 0) && (OS_MAX_FLAGS > 0)
/*
*********************************************************************************************************
* EVENT FLAGS
*********************************************************************************************************
*/
#define OS_FLAG_WAIT_CLR_ALL 0u /* Wait for ALL the bits specified to be CLR (i.e. 0) */
#define OS_FLAG_WAIT_CLR_AND 0u
#define OS_FLAG_WAIT_CLR_ANY 1u /* Wait for ANY of the bits specified to be CLR (i.e. 0) */
#define OS_FLAG_WAIT_CLR_OR 1u
#define OS_FLAG_WAIT_SET_ALL 2u /* Wait for ALL the bits specified to be SET (i.e. 1) */
#define OS_FLAG_WAIT_SET_AND 2u
#define OS_FLAG_WAIT_SET_ANY 3u /* Wait for ANY of the bits specified to be SET (i.e. 1) */
#define OS_FLAG_WAIT_SET_OR 3u
#define OS_FLAG_CONSUME 0x80u /* Consume the flags if condition(s) satisfied */
#define OS_FLAG_CLR 0u
#define OS_FLAG_SET 1u
#if OS_FLAGS_NBITS == 8 /* Determine the size of OS_FLAGS (8, 16 or 32 bits) */
typedef INT8U OS_FLAGS;
#endif
#if OS_FLAGS_NBITS == 16
typedef INT16U OS_FLAGS;
#endif
#if OS_FLAGS_NBITS == 32
typedef u32 OS_FLAGS;
#endif
typedef struct os_flag_grp { /* Event Flag Group */
u8 OSFlagType; /* Should be set to OS_EVENT_TYPE_FLAG */
void *OSFlagWaitList; /* Pointer to first NODE of task waiting on event flag */
OS_FLAGS OSFlagFlags; /* 8, 16 or 32 bit flags */
#if OS_FLAG_NAME_SIZE > 1
u8 OSFlagName[OS_FLAG_NAME_SIZE];
#endif
} OS_FLAG_GRP;
typedef struct os_flag_node { /* Event Flag Wait List Node */
void *OSFlagNodeNext; /* Pointer to next NODE in wait list */
void *OSFlagNodePrev; /* Pointer to previous NODE in wait list */
void *OSFlagNodeTCB; /* Pointer to TCB of waiting task */
void *OSFlagNodeFlagGrp; /* Pointer to Event Flag Group */
OS_FLAGS OSFlagNodeFlags; /* Event flag to wait on */
u8 OSFlagNodeWaitType; /* Type of wait: */
/* OS_FLAG_WAIT_AND */
/* OS_FLAG_WAIT_ALL */
/* OS_FLAG_WAIT_OR */
/* OS_FLAG_WAIT_ANY */
} OS_FLAG_NODE;
OS_EXT OS_FLAG_GRP OSFlagTbl[OS_MAX_FLAGS]; /* Table containing event flag groups */
OS_EXT OS_FLAG_GRP *OSFlagFreeList; /* Pointer to free list of event flag groups */
OS_FLAG_GRP *OSFlagCreate(OS_FLAGS flags, u8 *err);
OS_FLAG_GRP *OSFlagDel(OS_FLAG_GRP *pgrp, u8 opt, u8 *err);
OS_FLAGS OSFlagPend(OS_FLAG_GRP *pgrp, OS_FLAGS flags, u8 wait_type, u16 timeout, u8 *err);
OS_FLAGS OSFlagPost(OS_FLAG_GRP *pgrp, OS_FLAGS flags, u8 opt, u8 *err);
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* MESSAGE QUEUE DATA
*********************************************************************************************************
*/
#if (OS_Q_EN > 0) || (OS_TASKQ_EN > 0)
typedef struct os_q { /* QUEUE CONTROL BLOCK */
QS OSQIn;
QS OSQOut;
QS OSQSize; /* Size of queue (maximum number of entries) */
QS OSQEntries; /* Current number of entries in the queue */
void **OSQStart; /* Pointer to start of queue data */
} OS_Q;
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* TASK CONTROL BLOCK
*********************************************************************************************************
*/
typedef struct os_tcb {
OS_STK *OSTCBStkPtr; /* Pointer to current top of stack */
#if OS_CPU_MMU > 0
u8 *frame;
#endif
#if OS_TIME_SLICE_EN > 0
u8 slice_quanta; /* 时间片初始值 */
u8 slice_cnt; /* 时间片模式下的计数值 */
u16 OSTCBDly; /* Nbr ticks to delay task or, timeout waiting for event */
#endif
#if OS_TASKQ_EN > 0
OS_Q task_q;
#endif
#if OS_PARENT_TCB > 0
struct os_tcb *OSTCBParent;
#endif
#if OS_CHILD_TCB > 0
struct os_tcb *OSTCBChildNext;
#endif
#if OS_TIME_SLICE_EN > 0
struct os_tcb *OSTCBEventNext; /* Pointer to next TCB in the event waiting TCB list */
struct os_tcb *OSTCBEventPrev; /* Pointer to previous TCB in the event waiting TCB list */
struct os_tcb *OSTCBSliceNext; /* Pointer to next TCB in the time slice TCB list */
struct os_tcb *OSTCBSlicePrev; /* Pointer to previous TCB in the time slice TCB list */
#endif
#if OS_EVENT_EN
OS_EVENT *OSTCBEventPtr; /* Pointer to event control block */
#endif
#if (OS_Q_EN > 0) || (OS_TASKQ_EN > 0)
void *OSTCBMsg; /* Message received from OSMboxPost() or OSQPost() */
#endif
#if OS_FLAG_EN > 0
OS_FLAG_NODE *OSTCBFlagNode; /* Pointer to event flag node */
OS_FLAGS OSTCBFlagsRdy;
#endif
#if OS_TIME_SLICE_EN == 0
u16 OSTCBDly; /* Nbr ticks to delay task or, timeout waiting for event */
#endif
u8 OSTCBPrio; /* Task priority (0 == highest) */
u8 OSTCBStat; /* Task status */
u8 OSTCBPendTO; /* Flag indicating PEND timed out (TRUE == timed out) */
#if OS_TASK_DEL_EN > 0
u8 OSTCBDelReq; /* Indicates whether a task needs to delete itself */
#endif
u8 OSCoreAffinity; /* core */
u8 fork_thread;
OS_STK *OSTCBStkTos;
int *pid;
OS_STK stk_size;
OS_STK *p_stk_base;
char *name;
u32 timeout;
u32 RunTimeCounterStart;
u32 RunTimeCounterTotal;
} OS_TCB;
typedef struct os_tcb_list {
OS_TCB *ptcb;
#if OS_TIME_SLICE_EN > 0
OS_TCB *idle_ptcb;
#endif
} OS_TCB_LIST;
/*
*********************************************************************************************************
* MUTUAL EXCLUSION SEMAPHORE MANAGEMENT
*********************************************************************************************************
*/
#if OS_MUTEX_EN > 0
#if OS_MUTEX_ACCEPT_EN > 0
u8 OSMutexAccept(OS_EVENT *pevent);
#endif
u8 OSMutexCreate(OS_EVENT *pevent);
#if OS_MUTEX_DEL_EN > 0
u8 OSMutexDel(OS_EVENT *pevent, u8 opt);
#endif
u8 OSMutexPend(OS_EVENT *pevent, u16 timeout);
u8 OSMutexPost(OS_EVENT *pevent);
#if OS_MUTEX_QUERY_EN > 0
u8 OSMutexQuery(OS_EVENT *pevent, OS_MUTEX_DATA *p_mutex_data);
#endif
#endif
/*
*********************************************************************************************************
* MESSAGE QUEUE MANAGEMENT
*********************************************************************************************************
*/
#if (OS_Q_EN > 0)
#if OS_Q_ACCEPT_EN > 0
u8 OSQAccept(OS_EVENT *pevent, void *msg);
#endif
u8 OSQCreate(OS_EVENT *pevent, /*void **start, */QS size);
#if OS_Q_DEL_EN > 0
u8 OSQDel(OS_EVENT *pevent, u8 opt);
#endif
#if OS_Q_FLUSH_EN > 0
u8 OSQFlush(OS_EVENT *pevent);
#endif
u8 OSQPend(OS_EVENT *pevent, u16 timeout, void *msg);
#if OS_Q_POST_EN > 0
u8 OSQPost(OS_EVENT *pevent, void *msg);
#endif
#if OS_Q_POST_FRONT_EN > 0
u8 OSQPostFront(OS_EVENT *pevent, void *msg);
#endif
#if OS_Q_POST_OPT_EN > 0
u8 OSQPostOpt(OS_EVENT *pevent, void *msg, u8 opt);
#endif
#if OS_Q_QUERY_EN > 0
u16 OSQQuery(OS_EVENT *pevent);
#endif
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* SEMAPHORE MANAGEMENT
*********************************************************************************************************
*/
#if OS_SEM_EN > 0
#if OS_SEM_ACCEPT_EN > 0
u16 OSSemAccept(OS_EVENT *pevent);
#endif
u8 OSSemCreate(OS_EVENT *pevent, u16 cnt);
#if OS_SEM_DEL_EN > 0
u8 OSSemDel(OS_EVENT *pevent, u8 opt);
#endif
u8 OSSemPend(OS_EVENT *pevent, u16 timeout);
u8 OSSemPost(OS_EVENT *pevent);
#if OS_SEM_QUERY_EN > 0
u16 OSSemQuery(OS_EVENT *pevent);
#endif
#if OS_SEM_SET_EN > 0
u8 OSSemSet(OS_EVENT *pevent, u16 cnt);
#endif
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* TASK MANAGEMENT
*********************************************************************************************************
*/
#if OS_TASK_CHANGE_PRIO_EN > 0
u8 OSTaskChangePrio(char *name, u8 newprio);
#endif
#if OS_TASK_CREATE_EN > 0
u8 OSTaskCreate(void (*task)(void *p_arg), OS_TCB *task_tcb, void *p_arg
#if OS_CPU_MMU == 0
, OS_STK *ptos
#endif
, u8 prio
#if OS_TASKQ_EN > 0
, void **start, QS qsize
#endif
#if OS_TIME_SLICE_EN > 0
, u8 time_quanta
#endif
, s8 *name
);
#endif
u8 OSTaskQAccept(int argc, int *argv);
u8 OSTaskQPend(u16 timeout, int argc, int *argv);
u8 OSTaskQPost(const char *name, int argc, ...);
u8 OSTaskQFlush(const char *name);
u8 OSTaskQPostFront(const char *name, int argc, ...);
u8 OSTaskQQuery(const char *name, u8 *task_q_entries);
#if OS_TASK_DEL_EN > 0
u8 OSTaskDel(const char *name);
u8 OSTaskDelReq(const char *name);
void OSTaskDelRes(const char *name);
#endif
#if OS_TASK_SUSPEND_EN > 0
u8 OSTaskResume(const char *name);
u8 OSTaskSuspend(const char *name);
#endif
#if OS_TASK_QUERY_EN > 0
u8 OSTaskQuery(const char *name, OS_TCB *p_task_data);
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* TIME MANAGEMENT
*********************************************************************************************************
*/
void OSTimeDly(u16 ticks);
#if OS_TIME_GET_SET_EN > 0
u32 OSTimeGet(void);
void OSTimeSet(u32 ticks);
#endif
void OSTimeTick(void);
/*
*********************************************************************************************************
* MISCELLANEOUS
*********************************************************************************************************
*/
void OSInit(void);
void OSStart();
u16 OSVersion(void);
#endif
/*
*********************************************************************************************************
* GLOBAL VARIABLES
*********************************************************************************************************
*/
OS_EXT volatile u8 OSRunning; /* Flag indicating that kernel is running */
OS_EXT volatile OS_CPU_DATA OSRdyTbl;
OS_EXT volatile u32 OSIdleCtr; /* Idle counter */
OS_EXT OS_TCB *OSTCBCur[OS_CPU_CORE]; /* Pointer to currently running TCB */
OS_EXT OS_TCB *OSTCBHighRdy[OS_CPU_CORE]; /* Pointer to highest priority TCB R-to-R */
OS_EXT OS_TCB_LIST OSTCBPrioTbl[OS_MAX_TASKS + 1]; /* Table of pointers to created TCBs */
#if (OS_INT_NESTING == 1)
OS_EXT u8 OSIntNesting;
#elif (OS_INT_NESTING == 2)
extern int is_cpu_int_nesting();
#define OSIntNesting is_cpu_int_nesting()
#endif
#if OS_TIME_GET_SET_EN > 0
OS_EXT volatile u32 OSTime; /* Current value of system time (in ticks) */
#endif
/*
*********************************************************************************************************
* MISCELLANEOUS
*********************************************************************************************************
*/
/* void OSInit(void); */
void OSIntEnter(void);
void OSIntExit(void);
#if OS_SCHED_LOCK_EN > 0
void OSSchedLock(void);
void OSSchedUnlock(void);
#endif
u32 OS_HighPrio(OS_CPU_DATA table);
void OS_SchedRoundRobin(OS_TCB *ptcb);
void OS_InsertRdyListHead(OS_TCB *ptcb);
void OS_InsertRdyListTail(OS_TCB *ptcb);
void OS_InsertIdleList(OS_TCB *ptcb);
void OS_RemoveRdyList(OS_TCB *ptcb);
void OS_RemoveIdleList(OS_TCB *ptcb);
void OS_InsertListHead(OS_TCB *ptcb);
void OS_RemoveList(OS_TCB *ptcb);
/* void OSStart(); */
void OSStatInit(void);
/* u16 OSVersion(void); */
/*$PAGE*/
/*
*********************************************************************************************************
* INTERNAL FUNCTION PROTOTYPES
* (Your application MUST NOT call these functions)
*********************************************************************************************************
*/
#if OS_TASK_DEL_EN > 0
void OS_Dummy(void);
#endif
#if OS_EVENT_EN
void OS_ExchangePrio(OS_TCB *ptcba, OS_TCB *ptcbb);
#if OS_TIME_SLICE_EN > 0
OS_TCB *OS_EventHighestTask(OS_TCB *ptcb, u8 prio);
void OS_EventTaskRdy(OS_EVENT *pevent, OS_TCB *ptcb, void *msg, u8 msk);
#else
OS_TCB *OS_EventTaskRdy(OS_EVENT *pevent, void *msg, u8 msk);
#endif
void OS_EventTaskWait(OS_EVENT *pevent, OS_TCB *OSTCB);
void OS_EventTO(OS_EVENT *pevent, OS_TCB *OSTCB);
void OS_EventWaitListInit(OS_EVENT *pevent);
#endif
void OS_MemClr(u8 *pdest, u16 size);
void OS_MemCopy(u8 *pdest, u8 *psrc, u16 size);
#if OS_Q_EN > 0
void OS_QInit(void);
#endif
int OS_Sched(void);
void OS_TaskIdle(void *p_arg);
void OSIdleOtherCore(void);
void OSResumOtherCore(void);
void OS_CoreAffinitySet(const char *name, u8 Core);
/*$PAGE*/
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
* (Target Specific Functions)
*********************************************************************************************************
*/
#if OS_VERSION >= 204
void OSInitHookBegin(void);
void OSInitHookEnd(void);
#endif
#ifndef OS_ISR_PROTO_EXT
void OSIntCtxSw(void);
void OSStartHighRdy(void);
#endif
void OSTaskCreateHook(OS_TCB *ptcb);
void OSTaskDelHook(OS_TCB *ptcb);
#if OS_VERSION >= 251
void OSTaskIdleHook(void);
#endif
void OSTaskStatHook(void);
OS_STK *OSTaskStkInit(void(*p_task)(void *pd), void *p_arg, OS_STK *p_stk_base, u16 opt);
#if OS_TASK_SW_HOOK_EN > 0
void OSTaskSwHook(void);
#endif
#if OS_VERSION >= 204
void OSTCBInitHook(OS_TCB *ptcb);
#endif
#if OS_TIME_TICK_HOOK_EN > 0
void OSTimeTickHook(void);
#endif
extern void OS_TASK_DEL_HOOK(OS_TCB *ptcb) ;
/*$PAGE*/
/*
*********************************************************************************************************
* LOOK FOR MISSING #define CONSTANTS
*
* This section is used to generate ERROR messages at compile time if certain #define constants are
* MISSING in OS_CFG.H. This allows you to quickly determine the source of the error.
*
* You SHOULD NOT change this section UNLESS you would like to add more comments as to the source of the
* compile time error.
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* MUTUAL EXCLUSION SEMAPHORES
*********************************************************************************************************
*/
#ifndef OS_MUTEX_EN
#error "OS_CFG.H, Missing OS_MUTEX_EN: Enable (1) or Disable (0) code generation for MUTEX"
#else
#ifndef OS_MUTEX_ACCEPT_EN
#error "OS_CFG.H, Missing OS_MUTEX_ACCEPT_EN: Include code for OSMutexAccept()"
#endif
#ifndef OS_MUTEX_DEL_EN
#error "OS_CFG.H, Missing OS_MUTEX_DEL_EN: Include code for OSMutexDel()"
#endif
#ifndef OS_MUTEX_QUERY_EN
#error "OS_CFG.H, Missing OS_MUTEX_QUERY_EN: Include code for OSMutexQuery()"
#endif
#endif
/*
*********************************************************************************************************
* SEMAPHORES
*********************************************************************************************************
*/
#ifndef OS_SEM_EN
#error "OS_CFG.H, Missing OS_SEM_EN: Enable (1) or Disable (0) code generation for SEMAPHORES"
#else
#ifndef OS_SEM_ACCEPT_EN
#error "OS_CFG.H, Missing OS_SEM_ACCEPT_EN: Include code for OSSemAccept()"
#endif
#ifndef OS_SEM_DEL_EN
#error "OS_CFG.H, Missing OS_SEM_DEL_EN: Include code for OSSemDel()"
#endif
#ifndef OS_SEM_QUERY_EN
#error "OS_CFG.H, Missing OS_SEM_QUERY_EN: Include code for OSSemQuery()"
#endif
#ifndef OS_SEM_SET_EN
#error "OS_CFG.H, Missing OS_SEM_SET_EN: Include code for OSSemSet()"
#endif
#endif
/*
*********************************************************************************************************
* TASK MANAGEMENT
*********************************************************************************************************
*/
#ifndef OS_MAX_TASKS
#error "OS_CFG.H, Missing OS_MAX_TASKS: Max. number of tasks in your application"
#else
#if OS_MAX_TASKS < 2
#error "OS_CFG.H, OS_MAX_TASKS must be >= 2"
#endif
/* #if OS_MAX_TASKS > (OS_LOWEST_PRIO - OS_N_SYS_TASKS + 1) */
/* #error "OS_CFG.H, OS_MAX_TASKS must be <= OS_LOWEST_PRIO - OS_N_SYS_TASKS + 1" */
/* #endif */
#endif
#if OS_VERSION < 280
#if OS_LOWEST_PRIO > 63
#error "OS_CFG.H, OS_LOWEST_PRIO must be <= 63 in V2.7x or lower"
#endif
#endif
#if OS_VERSION >= 280
#if OS_LOWEST_PRIO > 254
#error "OS_CFG.H, OS_LOWEST_PRIO must be <= 254 in V2.8x and higher"
#endif
#endif
#ifndef OS_TASK_CHANGE_PRIO_EN
#error "OS_CFG.H, Missing OS_TASK_CHANGE_PRIO_EN: Include code for OSTaskChangePrio()"
#endif
#ifndef OS_TASK_CREATE_EN
#error "OS_CFG.H, Missing OS_TASK_CREATE_EN: Include code for OSTaskCreate()"
#endif
#ifndef OS_TASK_DEL_EN
#error "OS_CFG.H, Missing OS_TASK_DEL_EN: Include code for OSTaskDel()"
#endif
#ifndef OS_TASK_SUSPEND_EN
#error "OS_CFG.H, Missing OS_TASK_SUSPEND_EN: Include code for OSTaskSuspend() and OSTaskResume()"
#endif
#ifndef OS_TASK_QUERY_EN
#error "OS_CFG.H, Missing OS_TASK_QUERY_EN: Include code for OSTaskQuery()"
#endif
/*
*********************************************************************************************************
* TIME MANAGEMENT
*********************************************************************************************************
*/
#ifndef OS_TICKS_PER_SEC
#error "OS_CFG.H, Missing OS_TICKS_PER_SEC: Sets the number of ticks in one second"
#endif
#ifndef OS_TIME_DLY_HMSM_EN
#error "OS_CFG.H, Missing OS_TIME_DLY_HMSM_EN: Include code for OSTimeDlyHMSM()"
#endif
#ifndef OS_TIME_DLY_RESUME_EN
#error "OS_CFG.H, Missing OS_TIME_DLY_RESUME_EN: Include code for OSTimeDlyResume()"
#endif
#ifndef OS_TIME_GET_SET_EN
#error "OS_CFG.H, Missing OS_TIME_GET_SET_EN: Include code for OSTimeGet() and OSTimeSet()"
#endif
/*
*********************************************************************************************************
* MISCELLANEOUS
*********************************************************************************************************
*/
#ifndef OS_ARG_CHK_EN
#error "OS_CFG.H, Missing OS_ARG_CHK_EN: Enable (1) or Disable (0) argument checking"
#endif
#ifndef OS_CPU_HOOKS_EN
#error "OS_CFG.H, Missing OS_CPU_HOOKS_EN: uC/OS-II hooks are found in the processor port files when 1"
#endif
#ifndef OS_LOWEST_PRIO
#error "OS_CFG.H, Missing OS_LOWEST_PRIO: Defines the lowest priority that can be assigned"
#endif
#ifndef OS_SCHED_LOCK_EN
#error "OS_CFG.H, Missing OS_SCHED_LOCK_EN: Include code for OSSchedLock() and OSSchedUnlock()"
#endif
#ifndef OS_TASK_SW_HOOK_EN
#error "OS_CFG.H, Missing OS_TASK_SW_HOOK_EN: Allows you to include the code for OSTaskSwHook() or not"
#endif
#ifndef OS_TIME_TICK_HOOK_EN
#error "OS_CFG.H, Missing OS_TIME_TICK_HOOK_EN: Allows you to include the code for OSTimeTickHook() or not"
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,294 @@
SECTIONS
{
.data : ALIGN(4)
{
. = ALIGN(4);
system_data_start = .;
_video_subdev_begin = .;
PROVIDE(video_subdev_begin = .);
KEEP(*(.video_subdev.0))
KEEP(*(.video_subdev.1))
KEEP(*(.video_subdev.2))
KEEP(*(.video_subdev.3))
KEEP(*(.video_subdev.4))
KEEP(*(.video_subdev.5))
_video_subdev_end = .;
PROVIDE(video_subdev_end = .);
_audio_subdev_begin = .;
PROVIDE(audio_subdev_begin = .);
KEEP(*(.audio_subdev.0))
KEEP(*(.audio_subdev.1))
KEEP(*(.audio_subdev.2))
KEEP(*(.audio_subdev.3))
_audio_subdev_end = .;
PROVIDE(audio_subdev_end = .);
_iic_device_begin = .;
PROVIDE(iic_device_begin = .);
KEEP(*(.iic))
_iic_device_end = .;
PROVIDE(iic_device_end = .);
_avin_spi_device_begin = .;
PROVIDE(avin_spi_device_begin = .);
KEEP(*(.sw_spi))
_avin_spi_device_end = .;
PROVIDE(avin_spi_device_end = .);
_video_dev_begin = .;
PROVIDE(video_dev_begin = .);
KEEP(*(.video_device))
_video_dev_end = .;
PROVIDE(video_dev_end = .);
_key_driver_ops_begin = .;
PROVIDE(key_driver_ops_begin = .);
KEEP(*(.key_driver_ops))
_key_driver_ops_end = .;
PROVIDE(key_driver_ops_end = .);
_touch_driver_begin = .;
PROVIDE(touch_driver_begin = .);
KEEP(*(.touch_driver))
_touch_driver_end = .;
PROVIDE(touch_driver_end = .);
_static_hi_timer_begin = .;
PROVIDE(static_hi_timer_begin = .);
KEEP(*(.hi_timer))
_static_hi_timer_end = .;
PROVIDE(static_hi_timer_end = .);
_sys_cpu_timer_begin = .;
PROVIDE(sys_cpu_timer_begin = .);
KEEP(*(.sys_cpu_timer))
_sys_cpu_timer_end = .;
PROVIDE(sys_cpu_timer_end = .);
_sys_config_begin = .;
PROVIDE(sys_config_begin = .);
KEEP(*(.sys_cfg))
_sys_config_end = .;
PROVIDE(sys_config_end = .);
_sys_fat_begin = .;
PROVIDE(sys_fat_begin = .);
KEEP(*(.fs_fat))
_sys_fat_end = .;
PROVIDE(sys_fat_end = .);
_app_begin = .;
PROVIDE(app_begin = .);
KEEP(*(.app))
_app_end = .;
PROVIDE(app_end = .);
*(.crypto_ecdh_data)
*(.crypto_data)
*(.mem_data)
*(.os_port_data)
*(.os_str)
*(.os_data)
*(.uECC_data)
*(.ECDH_sample_data)
__movable_slot_start = .;
*(movable.slot.*);
__movable_slot_end = .;
system_data_end = .;
} > ram0
.bss (NOLOAD) :ALIGN(4)
{
system_bss_start = .;
. = ALIGN(4);
*(.os_bss)
*(.mem_heap)
*(.memp_memory_x)
*(.mem_bss)
*(.os_port_bss)
*(.uECC_bss)
*(.ECDH_sample_bss)
system_bss_end = .;
} > ram0
.text : ALIGN(4)
{
. = ALIGN(4);
system_text_start = .;
_device_node_begin = .;
PROVIDE(device_node_begin = .);
KEEP(*(.device))
_device_node_end = .;
PROVIDE(device_node_end = .);
config_target_begin = .;
PROVIDE(config_target_begin = .);
KEEP(*(.config_target))
config_target_end = .;
PROVIDE(config_target_end = .);
system_code_begin = .;
KEEP(*(.system.*.text))
system_code_end = .;
. = ALIGN(4);
system_code_size = system_code_end - system_code_begin;
vfs_ops_begin = .;
KEEP(*(.vfs_operations))
vfs_ops_end = .;
_lib_version_begin = .;
PROVIDE(lib_version_begin = .);
KEEP(*(.lib_version))
_lib_version_end = .;
PROVIDE(lib_version_end = .);
_initcall_begin = .;
PROVIDE(initcall_begin = .);
KEEP(*(.initcall))
_initcall_end = .;
PROVIDE(initcall_end = .);
_early_initcall_begin = .;
PROVIDE(early_initcall_begin = .);
KEEP(*(.early.initcall))
_early_initcall_end = .;
PROVIDE(early_initcall_end = .);
_late_initcall_begin = .;
PROVIDE(late_initcall_begin = .);
KEEP(*(.late.initcall))
_late_initcall_end = .;
PROVIDE(late_initcall_end = .);
_platform_initcall_begin = .;
PROVIDE(platform_initcall_begin = .);
KEEP(*(.platform.initcall))
_platform_initcall_end = .;
PROVIDE(platform_initcall_end = .);
_module_initcall_begin = .;
PROVIDE(module_initcall_begin = .);
KEEP(*(.module.initcall))
_module_initcall_end = .;
PROVIDE(module_initcall_end = .);
_sys_event_handler_begin = .;
PROVIDE(sys_event_handler_begin = .);
KEEP(*(.sys_event.4.handler))
KEEP(*(.sys_event.3.handler))
KEEP(*(.sys_event.2.handler))
KEEP(*(.sys_event.1.handler))
KEEP(*(.sys_event.0.handler))
_sys_event_handler_end = .;
PROVIDE(sys_event_handler_end = .);
_syscfg_arg_begin = .;
PROVIDE(syscfg_arg_begin = .);
KEEP(*(.syscfg.arg))
_syscfg_arg_end = .;
PROVIDE(syscfg_arg_end = .);
_syscfg_handler_begin = .;
PROVIDE(syscfg_handler_begin = .);
KEEP(*(.syscfg.handler))
_syscfg_handler_end = .;
PROVIDE(syscfg_handler_end = .);
_syscfg_ops_begin = .;
PROVIDE(syscfg_ops_begin = .);
KEEP(*(.syscfg.2.ops))
KEEP(*(.syscfg.1.ops))
KEEP(*(.syscfg.0.ops))
_syscfg_ops_end = .;
PROVIDE(syscfg_ops_end = .);
_server_info_begin = .;
PROVIDE(server_info_begin = .);
KEEP(*(.server_info))
_server_info_end = .;
PROVIDE(server_info_end = .);
_bus_device_begin = .;
PROVIDE(bus_device_begin = .);
KEEP(*(.bus_device))
_bus_device_end = .;
PROVIDE(bus_device_end = .);
_sys_power_hal_ops_begin = .;
PROVIDE(sys_power_hal_ops_begin = .);
KEEP(*(.sys_power_hal_ops))
_sys_power_hal_ops_end = .;
PROVIDE(sys_power_hal_ops_end = .);
crypto_begin = .;
*(.crypto_ecdh_code)
*(.crypto_ecdh_const)
*(.crypto_bigint_code)
*(.crypto_bigint_const)
*(.crypto_code)
*(.crypto_const)
*(.ECDH_sample_code)
*(.ECDH_sample_const)
*(.uECC_code)
*(.uECC_const)
*(.hmac_code)
*(.hmac_const)
*(.hash_sample_code)
*(.hash_sample_const)
*(.aes_cmac_sample_code)
*(.aes_cmac_sample_const)
crypto_end = .;
crypto_size = . - crypto_begin;
*(.mem_code)
*(.mem_const)
*(.os_port_code)
*(.os_port_const)
*(.os_const)
*(.math_fast_funtion_code)
__movable_function_start = .;
*(movable.text.*);
*(movable.stub.*);
*(movable.region.*);
/* *(.movable.code*) */
__movable_function_end = .;
__movable_function_size = __movable_function_end - __movable_function_start;
system_text_end = .;
system_code_total_size = system_text_end - system_text_start;
} > code0
.data_code ALIGN(32):
{
*(.os_code)
} > ram0
}

View File

@ -0,0 +1,103 @@
#ifndef __POWER_MANAGE_H_
#define __POWER_MANAGE_H_
#include "generic/typedef.h"
#ifdef __cplusplus
extern "C" {
#endif
enum {
DEVICE_EVENT_POWER_SHUTDOWN = 0x10,
DEVICE_EVENT_POWER_STARTUP,
DEVICE_EVENT_POWER_PERCENT,
DEVICE_EVENT_POWER_CHARGER_IN,
DEVICE_EVENT_POWER_CHARGER_OUT
};
#define PWR_SCAN_TIMES 3
#define PWR_DELAY_INFINITE 0xffffffff
#define PWR_WKUP_PORT "wkup_port"
#define PWR_WKUP_ALARM "wkup_alarm"
#define PWR_WKUP_PWR_ON "wkup_pwr_on"
#define PWR_WKUP_ABNORMAL "wkup_abnormal"
#define PWR_WKUP_SHORT_KEY "wkup_short_key"
struct sys_power_hal_ops {
void (*init)(void);
void (*poweroff)(void *arg);
int (*wakeup_check)(char *reason, int max_len);
int (*port_wakeup_config)(const char *port, int enable);
int (*alarm_wakeup_config)(u32 sec, int enable);
int (*get_battery_voltage)(void);
int (*get_battery_percent)(void);
int (*charger_online)(void);
};
extern const struct sys_power_hal_ops sys_power_hal_ops_begin[];
extern const struct sys_power_hal_ops sys_power_hal_ops_end[];
#define REGISTER_SYS_POWER_HAL_OPS(ops) \
static const struct sys_power_hal_ops ops sec(.sys_power_hal_ops)
void sys_power_early_init();
/*
* @brief 断电关机,不释放资源
*/
void sys_power_poweroff(void *arg);
/*
* @brief 软关机触发DEVICE_EVENT_POWER_SHUTDOWN事件app捕获事件释放资源再调用sys_power_poweroff()
*/
void sys_power_shutdown();
int sys_power_set_port_wakeup(const char *port, int enable);
int sys_power_set_alarm_wakeup(u32 sec, int enable);
const char *sys_power_get_wakeup_reason();
void sys_power_clr_wakeup_reason(const char *str);
int sys_power_get_battery_voltage();
int sys_power_get_battery_persent();
int sys_power_is_charging();
int sys_power_charger_online(void);
/*
* @brief 倒计时自动关机
* @parm dly_secs 延时关机时间赋值0为永不关机
* @return none
*/
void sys_power_auto_shutdown_start(u32 dly_secs);
void sys_power_auto_shutdown_pause();
void sys_power_auto_shutdown_resume();
void sys_power_auto_shutdown_clear();
void sys_power_auto_shutdown_stop();
int sys_power_low_voltage(u32 voltage);
/*
* @brief 低电延时关机
* @parm p_low_percent 低电电量百分比
* @parm dly_secs 延时关机时间赋值0为立即关机赋值PWR_DELAY_INFINITE为永不关机
* @return none
*/
void sys_power_low_voltage_shutdown(u32 voltage, u32 dly_secs);
/*
* @brief 插拔延时关机
* @parm dly_secs 延时关机时间赋值0为立即关机赋值PWR_DELAY_INFINITE为永不关机
* @return none
*/
void sys_power_charger_off_shutdown(u32 dly_secs);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,85 @@
#ifndef SERVER_H
#define SERVER_H
#include "generic/typedef.h"
#include "system/task.h"
#include "spinlock.h"
#include "list.h"
#define REQ_COMPLETE_CALLBACK 0x01000000
#define REQ_WAIT_COMPLETE 0x02000000
#define REQ_HI_PRIORITY 0x04000000
#define REQ_TYPE_MASK 0x00ffffff
struct server_req {
int type;
int err;
void *server_priv;
struct list_head entry;
struct server *server;
void *user;
const char *owner;
OS_SEM sem;
union {
int state;
void (*func)(void *, void *, int);
} complete;
u32 arg[0];
};
struct server_info {
const char *name;
u16 reqlen;
u8 reqnum;
void *(*open)(void *, void *);
void (*close)(void *);
};
#define REQ_BUF_LEN 512
struct server {
bool avaliable;
void *server;
OS_SEM sem;
OS_MUTEX mutex;
spinlock_t lock;
struct list_head *req_buf;
struct list_head free;
struct list_head pending;
const struct server_info *info;
const char *owner;
void *handler_priv;
void (*event_handler)(void *, int argc, int *argv);
};
#define SERVER_REGISTER(info) \
const struct server_info info sec(.server_info)
#define server_load(server) \
load_module(server)
struct server *server_open(const char *name, void *arg);
void server_register_event_handler(struct server *server, void *priv,
void (*handler)(void *, int argc, int *argv));
void server_close(struct server *server);
int server_request(struct server *server, int req_type, void *arg);
int server_request_async(struct server *server, int req_type, void *arg, ...);
int server_req_complete(struct server_req *req);
int server_event_handler(void *_server, int argc, int *argv);
#endif

View File

@ -0,0 +1,101 @@
/***********************************Jieli tech************************************************
File : nor_fs.h
By : Huxi
Email: xi_hu@zh-jieli.com
date : 2016-11-30 14:30
********************************************************************************************/
#ifndef _NOR_FS_H_
#define _NOR_FS_H_
// #include "sdk_cfg.h"
#include "typedef.h"
// #include "system/includes.h"
// #define SPI_REC_EN 1
#define NORFS_DATA_LEN 16
#define REC_FILE_END 0xFE
//文件索引
typedef struct __RECF_INDEX_INFO {
u16 index; //文件索引号
u16 sector; //文件所在扇区
} RECF_INDEX_INFO ;
#define FLASH_PAGE_SIZE 256
//文件系统句柄
typedef struct __RECFILESYSTEM {
RECF_INDEX_INFO index;
u8 buf[FLASH_PAGE_SIZE];
u16 total_file;
u16 first_sector;
u16 last_sector;
// u8 *buf;
u8 sector_size;
void (*eraser)(u32 address);
s32(*read)(u8 *buf, u32 addr, u32 len);
s32(*write)(u8 *buf, u32 addr, u32 len);
} RECFILESYSTEM, *PRECFILESYSTEM ;
//文件句柄
typedef struct __REC_FILE {
RECF_INDEX_INFO index;
RECFILESYSTEM *pfs;
u32 addr;
char priv_data[NORFS_DATA_LEN];
u32 len;
u32 w_len;
u32 rw_p;
u16 sr;
} REC_FILE;
enum {
NOR_FS_SEEK_SET = 0,
NOR_FS_SEEK_CUR = 0x01
};
// enum {
// NOR_FS_SEEK_SET = 0x01,
// NOR_FS_SEEK_CUR = 0x02
// };
typedef struct __nor_fs_hdl {
u16 index;
RECFILESYSTEM *recfs;
REC_FILE *recfile;
} NOR_FS_HDL;
u8 recf_seek(REC_FILE *pfile, u8 type, int offsize);
u16 recf_read(REC_FILE *pfile, u8 *buff, u16 btr);
u16 recf_write(REC_FILE *pfile, u8 *buff, u16 btw);
u32 create_recfile(RECFILESYSTEM *pfs, REC_FILE *pfile);
u32 close_recfile(REC_FILE *pfile);
u32 open_recfile(u32 index, RECFILESYSTEM *pfs, REC_FILE *pfile);
void recf_save_sr(REC_FILE *pfile, u16 sr);
int music_flash_file_set_index(u8 file_sel, u32 index);
u32 recfs_scan(RECFILESYSTEM *pfs);
void init_nor_fs(RECFILESYSTEM *pfs, u16 sector_start, u16 sector_end, u8 sector_size);
u32 nor_fs_init(void);
int nor_fs_set_rec_capacity(int capacity); //需要先设置容量。
int nor_fs_ops_init(void);
int recfs_scan_ex();
u32 nor_get_capacity(void);
u32 flashinsize_rec_get_capacity(void);
int sdfile_rec_scan_ex();
void rec_clear_norfs_fileindex(void);
void clear_norfs_fileindex(void);
u32 _sdfile_rec_init(void);
int set_rec_capacity(int capacity); //需要先设置容量。
int sdfile_rec_ops_init(void);
u32 nor_get_index(void);
u32 flashinsize_rec_get_index(void);
int nor_set_offset_addr(int offset);
#endif

View File

@ -0,0 +1,145 @@
#ifndef SYS_SPINLOCK_H
#define SYS_SPINLOCK_H
#include "typedef.h"
#include "cpu.h"
#include "irq.h"
struct __spinlock {
volatile u32 rwlock;
};
typedef struct __spinlock spinlock_t;
#if CPU_CORE_NUM > 1
#define preempt_disable() \
__local_irq_disable()
#define preempt_enable() \
__local_irq_enable()
#else
#define preempt_disable() \
local_irq_disable()
#define preempt_enable() \
local_irq_enable()
#endif
#if CPU_CORE_NUM > 1
#define spin_acquire(lock) \
do { \
arch_spin_lock(lock); \
}while(0)
#define spin_release(lock) \
do { \
arch_spin_unlock(lock); \
}while(0)
#else
#define spin_acquire(lock) \
do { \
}while(0)
#define spin_release(lock) \
do { \
}while(0)
#endif
#define DEFINE_SPINLOCK(x) \
spinlock_t x = { .rwlock = 0 }
static inline void spin_lock_init(spinlock_t *lock)
{
lock->rwlock = 0;
}
extern u32 spin_lock_cnt[];
#if 1
static inline void spin_lock(spinlock_t *lock)
{
preempt_disable();
/*ASSERT(spin_lock_cnt[current_cpu_id()] == 0);
spin_lock_cnt[current_cpu_id()] = 1;*/
spin_acquire(lock);
}
static inline void spin_unlock(spinlock_t *lock)
{
/*spin_lock_cnt[current_cpu_id()] = 0;*/
spin_release(lock);
preempt_enable();
}
#else
#define spin_lock(lock) \
do { \
preempt_disable(); \
if (!(T2_CON & (1<<0))) { \
T2_CNT = 0; \
T2_PRD = 120000000 / 10; \
T2_CON = 1; \
} \
spin_lock_cnt[current_cpu_id()] = T2_CNT; \
spin_acquire(lock); \
} while (0)
#define spin_unlock(lock) \
do { \
u32 t = T2_CNT;\
if(t < spin_lock_cnt[current_cpu_id()]) \
t += T2_PRD - spin_lock_cnt[current_cpu_id()]; \
else \
t -= spin_lock_cnt[current_cpu_id()]; \
spin_release(lock); \
preempt_enable(); \
if (t > 100000) { /*120000 == 1ms*/ \
printf("???????spinlock: %d, %s\n", t, __func__); \
} \
} while(0)
#endif
/*#define spin_lock_irqsave(lock, flags) \
do { \
local_irq_save(flags); \
spin_acquire((lock)); \
}while(0)
#define spin_unlock_irqrestore(lock, flags) \
do { \
spin_release((lock)); \
local_irq_restore(flags); \
}while(0) */
#endif

View File

@ -0,0 +1,50 @@
#ifndef SYS_TIME_H
#define SYS_TIME_H
#include "typedef.h"
struct sys_time {
u16 year;
u8 month;
u8 day;
u8 hour;
u8 min;
u8 sec;
};
#if 0
struct tm {
int tm_sec; /* Seconds. [0-60] (1 leap second) */
int tm_min; /* Minutes. [0-59] */
int tm_hour; /* Hours. [0-23] */
int tm_mday; /* Day. [1-31] */
int tm_mon; /* Month. [0-11] */
int tm_year; /* Year - 1900. */
int tm_wday; /* Day of week. [0-6] */
int tm_yday; /* Days in year.[0-365] */
int tm_isdst; /* DST. [-1/0/1]*/
# ifdef __USE_MISC
long int tm_gmtoff; /* Seconds east of UTC. */
const char *tm_zone; /* Timezone abbreviation. */
# else
long int __tm_gmtoff; /* Seconds east of UTC. */
const char *__tm_zone; /* Timezone abbreviation. */
# endif
};
#endif
#endif

View File

@ -0,0 +1,298 @@
#ifndef __JL_CFG_DEC_H__
#define __JL_CFG_DEC_H__
#include "typedef.h"
struct btif_item {
u16 id;
u16 data_len;
};
struct syscfg_operataions {
int (*init)(void);
int (*check_id)(u16 item_id);
int (*read)(u16 item_id, u8 *buf, u16 len);
int (*write)(u16 item_id, u8 *buf, u16 len);
int (*dma_write)(u16 item_id, u8 *buf, u16 len);
int (*read_string)(u16 item_id, u8 *buf, u16 len, u8 ver);
u8 *(*ptr_read)(u16 item_id, u16 *len);
};
#define REGISTER_SYSCFG_OPS(cfg, pri) \
const struct syscfg_operataions cfg SEC_USED(.syscfg.pri.ops)
//=================================================================================//
// 系统配置项(VM, BTIF, cfg_bin)读写接口 //
//接口说明: //
// 1.输入参数 //
// 1)item_id: 配置项ID号, 由本文件统一分配; //
// 2)buf: 用于存储read/write数据内容; //
// 3)len: buf的长度(byte), buf长度必须大于等于read/write数据长度; //
// 2.返回参数: //
// 1)执行正确: 返回值等于实际上所读到的数据长度(大于0); //
// 2)执行错误: 返回值小于等于0, 小于0表示相关错误码; //
// 3.读写接口使用注意事项: //
// 1)不能在中断里调用写(write)接口; //
// 2)调用本读写接口时应该习惯性判断返回值来检查read/write动作是否执行正确; //
//=================================================================================//
/* --------------------------------------------------------------------------*/
/**
* @brief 读取对应配置项的内容
*
* @param [in] item_id 配置项ID号
* @param [out] buf 用于存储read数据内容
* @param [in] len buf的长度(byte), buf长度必须大于等于read数据长度
*
* @return 1)执行正确: 返回值等于实际上所读到的数据长度(大于0);
* 2)执行错误: 返回值小于等于0, 小于0表示相关错误码;
*/
/* --------------------------------------------------------------------------*/
int syscfg_read(u16 item_id, void *buf, u16 len);
/* --------------------------------------------------------------------------*/
/**
* @brief 读取cfg_tool.bin对应配置项的内容
*
* @param [in] item_id 配置项ID号
* @param [out] buf 用于存储read数据内容
* @param [in] len buf的长度(byte), buf长度必须大于等于read数据长度
*
* @return 1)执行正确: 返回值等于实际上所读到的数据长度(大于0);
* 2)执行错误: 返回值小于等于0, 小于0表示相关错误码;
*/
/* --------------------------------------------------------------------------*/
int syscfg_read_btmac_blemac_from_bin(u16 item_id, void *buf, u16 len);
/* --------------------------------------------------------------------------*/
/**
* @brief 写入对应配置项的内容
*
* @param [in] item_id 配置项ID号
* @param [in] buf 用于存储write数据内容
* @param [in] len buf的长度(byte), buf长度必须大于等于write数据长度
*
* @return 1)执行正确: 返回值等于实际上所读到的数据长度(大于0);
* 2)执行错误: 返回值小于等于0, 小于0表示相关错误码;
*/
/* --------------------------------------------------------------------------*/
int syscfg_write(u16 item_id, void *buf, u16 len);
/* --------------------------------------------------------------------------*/
/**
* @brief 以dma的方式写入对应配置项的内容, 请注意buf地址需要按照4byte对齐
*
* @param [in] item_id 配置项ID号
* @param [in] buf 用于存储write数据内容
* @param [in] len buf的长度(byte), buf长度必须大于等于write数据长度
*
* @return 1)执行正确: 返回值等于实际上所读到的数据长度(大于0);
* 2)执行错误: 返回值小于等于0, 小于0表示相关错误码;
*/
/* --------------------------------------------------------------------------*/
int syscfg_dma_write(u16 item_id, void *buf, u16 len);
/* --------------------------------------------------------------------------*/
/**
* @brief 读取同一个配置项存在多份数据中的某一份数据, ver读取表示第几份数据, ver从 0 开始;
* @brief 典型应用: 读取配置项CFG_BT_NAME中多个蓝牙名中的某一个蓝牙名;
*
* @param [in] item_id 配置项ID号
* @param [in] buf 用于存储read数据内容
* @param [in] len buf的长度(byte), buf长度必须大于等于read数据长度
* @param [in] ver 读取表示第几份数据
*
* @return 1)执行正确: 返回值等于实际上所读到的数据长度(大于0);
* 2)执行错误: 返回值小于等于0, 小于0表示相关错误码;
*/
/* --------------------------------------------------------------------------*/
int syscfg_read_string(u16 item_id, void *buf, u16 len, u8 ver);
/* --------------------------------------------------------------------------*/
/**
* @brief 获取配置项的地址
* @brief 注: 只支持cfg_tools.bin文件中的配置项读取
* @param [in] item_id 配置项ID号
* @param [out] len 配置项长度
*
* @return 配置项地址指针(可以用cpu直接访问);
*/
/* --------------------------------------------------------------------------*/
u8 *syscfg_ptr_read(u16 item_id, u16 *len);
//==================================================================================================//
// 配置项ID分配说明 //
// 1.配置项ID号根据存储区域进行分配; //
// 2.存储区域有3个: 1)VM区域; 2)sys_cfg.bin; 3)BTIF区域 //
// 3.配置项ID号分配如下: //
// 0)[0]: 配置项ID号0为配置项工具保留ID号; //
// 1)[ 1 ~ 49]: 共49项, 预留给用户自定义, 只存于VM区域; //
// 2)[ 50 ~ 99]: 共50项, sdk相关配置项, 只存于VM区域; //
// 3)[100 ~ 127]: 共28项, sdk相关配置项, 可以存于VM区域, sys_cfg.bin(作为默认值) 和 BTIF区域; //
// 4)[512 ~ 700]: 共188项, sdk相关配置项, 只存于sys_cfg.bin; //
//==================================================================================================//
//=================================================================================//
// 用户自定义配置项[1 ~ 49] //
//=================================================================================//
#define CFG_USER_DEFINE_BEGIN 1
#define CFG_USER_DEFINE_END 49
//=================================================================================//
// 只存VM配置项[50 ~ 99] //
//=================================================================================//
#define CFG_STORE_VM_ONLY_BEGIN 50
#define AT_CHAR_DEV_NAME 51
#define CFG_STORE_VM_ONLY_END 99
//=================================================================================//
// 可以存于VM, sys_cfg.bin(默认值)和BTIF区域的配置项[100 ~ 127] //
// (VM支持扩展到511) //
//=================================================================================//
#define CFG_STORE_VM_BIN_BTIF_BEGIN 100
#define CFG_STORE_VM_BIN_BTIF_END (VM_ITEM_MAX_NUM - 1) //在app_cfg文件中配置128/256
//==================================================================================================//
//ID号分配方案:
// 1) 与APP CASE 相关的ID (0 ~ 50);
// 3) lib库保留ID(蓝牙, trim 值) (范围: 61 ~ 127); //67项
// 4) 与app_case 扩展ID号需要更大的ram资源(128 ~ 511);
//==================================================================================================//
//=================================================================================//
// SDK库保留配置项[61 ~ 127] //
//=================================================================================//
#define CFG_REMOTE_DB_INFO 61
#define CFG_REMOTE_DB_00 62
#define CFG_REMOTE_DB_01 63
#define CFG_REMOTE_DB_02 64
#define CFG_REMOTE_DB_03 65
#define CFG_REMOTE_DB_04 66
#define CFG_REMOTE_DB_05 67
#define CFG_REMOTE_DB_06 68
#define CFG_REMOTE_DB_07 69
#define CFG_REMOTE_DB_08 70
#define CFG_REMOTE_DB_09 71
#define CFG_REMOTE_DB_10 72
#define CFG_REMOTE_DB_11 73
#define CFG_REMOTE_DB_12 74
#define CFG_REMOTE_DB_13 75
#define CFG_REMOTE_DB_14 76
#define CFG_REMOTE_DB_15 77
#define CFG_REMOTE_DB_16 78
#define CFG_REMOTE_DB_17 79
#define CFG_REMOTE_DB_18 80
#define CFG_REMOTE_DB_19 81
// #define CFG_NULL 82
#define CFG_BLE_MODE_INFO 83
#define CFG_TWS_PAIR_AA 84
#define CFG_TWS_CONNECT_AA 85
#define CFG_MUSIC_VOL 86
#define CFG_DAC_DTB 88
#define CFG_MC_BIAS 89
#define CFG_POR_FLAG 90
#define CFG_MIC_LDO_VSEL 91
#define CFG_DAC_TRIM_INFO 92
#define CFG_BT_TRIM_INFO 93
#define CFG_ANC_INFO 94
#define CFG_TWS_LOCAL_ADDR 95
#define CFG_TWS_REMOTE_ADDR 96
#define CFG_TWS_COMMON_ADDR 97
#define CFG_TWS_CHANNEL 98
#define VM_PMU_VOLTAGE 99
// #define CFG_NULL 100
//=========== btif & cfg_tool.bin & vm ============//
#define CFG_BT_NAME 101
#define CFG_BT_MAC_ADDR 102
#define CFG_BLE_NAME 103
#define CFG_BLE_MAC_ADDR 104
#define VM_OLD_RTC_TIME 105
#define VM_OLD_REAL_TIME 106
#define VM_BLE_LOCAL_INFO 109
#define CFG_BT_FRE_OFFSET 110
#define VM_GFPS_KEY_LIST 111
#define VM_GFPS_NAME 112
// #define CFG_NULL 113
#define VM_TME_AUTH_COOKIE 114
// #define CFG_NULL 115
#define VM_RTC_TRIM 116
#define VM_BLE_REMOTE_DB_INFO 117
#define VM_BLE_REMOTE_DB_00 118
#define VM_BLE_REMOTE_DB_01 119
#define VM_BLE_REMOTE_DB_02 120
#define VM_BLE_REMOTE_DB_03 121
#define VM_BLE_REMOTE_DB_04 122
#define VM_BLE_REMOTE_DB_05 123
#define VM_BLE_REMOTE_DB_06 124
#define VM_BLE_REMOTE_DB_07 125
#define VM_BLE_REMOTE_DB_08 126
#define VM_BLE_REMOTE_DB_09 127
#define CFG_ONLINE_EQ_DRC_DATA_ID 254//在线调试保存参数的id
#define CFG_ONLINE_SAVE_ID 255//在线保存文件大小的id
//=================================================================================//
// 只存于sys_cfg.bin的配置项[512 ~ 700] //
//=================================================================================//
#define CFG_STORE_BIN_ONLY_BEGIN 512
//硬件类配置项[513 ~ 600]
#define CFG_UART_ID 513
#define CFG_HWI2C_ID 514
#define CFG_SWI2C_ID 515
#define CFG_HWSPI_ID 516
#define CFG_SWSPI_ID 517
#define CFG_SD_ID 518
#define CFG_USB_ID 519
#define CFG_LCD_ID 520
#define CFG_TOUCH_ID 521
#define CFG_IOKEY_ID 522
#define CFG_ADKEY_ID 523
#define CFG_AUDIO_ID 524
#define CFG_VIDEO_ID 525
#define CFG_WIFI_ID 526
#define CFG_NIC_ID 527
#define CFG_LED_ID 528
#define CFG_POWER_MANG_ID 529
#define CFG_IRFLT_ID 530
#define CFG_PLCNT_ID 531
#define CFG_PWMLED_ID 532
#define CFG_RDEC_ID 533
#define CFG_CHARGE_STORE_ID 534
#define CFG_CHARGE_ID 535
#define CFG_LOWPOWER_V_ID 536
#define CFG_MIC_TYPE_ID 537
#define CFG_COMBINE_SYS_VOL_ID 538
#define CFG_COMBINE_CALL_VOL_ID 539
#define CFG_LP_TOUCH_KEY_ID 540
//蓝牙类配置项[601 ~ 650]
#define CFG_BT_RF_POWER_ID 601
#define CFG_TWS_PAIR_CODE_ID 602
#define CFG_AUTO_OFF_TIME_ID 603
#define CFG_AEC_ID 604
#define CFG_UI_TONE_STATUS_ID 605
#define CFG_KEY_MSG_ID 606
#define CFG_LRC_ID 607
#define CFG_DMS_ID 609
#define CFG_ANC_ID 610
#define CFG_SMS_DNS_ID 612 //单mic神经网络降噪
#define CFG_DMS_DNS_ID 613 //双mic神经网络降噪
#define CFG_DMS_FLEXIBLE_ID 614 //灵活可变双mic降噪
#define CFG_BLE_RF_POWER_ID 615
#define CFG_DMS_DNS_FLEXIBLE_ID 616 //灵活可变双mic神经网络降噪
#define CFG_TMS_DNS_ID 617 //3mic神经网络降噪参数
//其它类配置项[651 ~ 700]
#define CFG_STORE_BIN_ONLY_END 700
#endif

42
include_lib/system/task.h Normal file
View File

@ -0,0 +1,42 @@
#ifndef TASK_PRIORITY_H
#define TASK_PRIORITY_H
#include "os/os_api.h"
struct task_info {
const char *name;
u8 prio;
u8 core;
u16 stack_size;
u16 qsize;
};
typedef OS_SEM sem_t;
typedef OS_MUTEX mutex_t;
int task_create(void (*task)(void *p), void *p, const char *name);
int task_exit(const char *name);
int task_delete(const char *name);
int task_kill(const char *name);
#endif

308
include_lib/system/timer.h Normal file
View File

@ -0,0 +1,308 @@
#ifndef SYS_TIMER_H
#define SYS_TIMER_H
#include "typedef.h"
#include "generic/list.h"
struct static_sys_timer {
void (*func)(void *priv);
void *priv;
u32 msec;
u32 jiffies;
};
struct sys_usec_timer {
void (*func)(void *priv);
void *priv;
const char *owner;
struct sys_cpu_timer *timer;
};
#define SYS_HI_TIMER_ADD(_func, _priv, _msec) \
static struct static_sys_timer hi_timer sec(.hi_timer) = { \
.func = _func, \
.priv = _priv, \
.msec = _msec, \
}
extern struct static_sys_timer static_hi_timer_begin[];
extern struct static_sys_timer static_hi_timer_end[];
#define list_for_each_static_hi_timer(p) \
for (p=static_hi_timer_begin; p<static_hi_timer_end; p++)
struct sys_cpu_timer {
u8 busy;
void *priv;
void (*set)(u32 usec);
void (*unset)();
};
#define DEFINE_SYS_CPU_TIMER(t) \
struct sys_cpu_timer t sec(.sys_cpu_timer);
#define REGISTER_SYS_CPU_TIMER(t) \
struct sys_cpu_timer t sec(.sys_cpu_timer)
extern struct sys_cpu_timer sys_cpu_timer_begin[];
extern struct sys_cpu_timer sys_cpu_timer_end[];
#define list_for_each_cpu_usec_timer(p) \
for (p = sys_cpu_timer_begin; p < sys_cpu_timer_end; p++)
/*
* System Timer
*/
/**
* @brief 添加ms级系统非timeout类型定时任务。
*
* @param [in] priv 定时任务处理函数的输入参数
* @param [in] func 定时任务处理函数
* @param [in] msec 定时时间
*
* @return 定时器分配的ID
*
* @note
* 1、系统会进入低功耗节拍不会丢失定时结束会唤醒系统
* 2、sys_timer由systimer线程提供时基属于同步接口
* 也就是说在哪个线程add的sys_timer当定时时基到了,
* systimer线程会发事件通知对应的add线程响应回调函数被执行
* 3、与sys_timer_del成对使用。
*/
u16 sys_timer_add(void *priv, void (*func)(void *priv), u32 msec);
/**
* @brief 删除ms级非timeout类型定时任务。
*
* @param [in] id 要删除的任务ID
*
* @note
* 1、与sys_timer_add成对使用。
*/
void sys_timer_del(u16);
/**
* @brief 添加ms级系统timeout类型定时任务。
*
* @param [in] priv 定时任务处理函数的输入参数
* @param [in] func 定时任务处理函数
* @param [in] msec 定时时间
*
* @return 定时器分配的id号
*
* @note
* 1、系统会进入低功耗节拍不会丢失定时结束会唤醒系统
* 2、sys_timeout由systimer线程提供时基属于同步接口
* 也就是说在哪个线程add的sys_timeout定时时基到了
* systimer线程会发事件通知对应的add线程响应回调函数被执行
* 3、timeout回调只会被执行一次
* 4、与sys_timerout_del成对使用。
*/
u16 sys_timeout_add(void *priv, void (*func)(void *priv), u32 msec);
/**
* @brief 删除ms级timeout类型定时任务。
*
* @param [in] id 要删除的任务ID
*
* @note
* 1、与sys_timerout_add成对使用。
*/
void sys_timeout_del(u16);
/**
* @brief 重置ms级定时任务定时时间。
*
* @param [in] id 要修改的任务ID
*
* @note
* 1、重置之后重新计时。
*/
void sys_timer_re_run(u16 id);
/**
* @brief 修改ms级定时任务处理函数的输入参数。
*
* @param [in] id 要修改的任务ID
* @param [in] priv 处理函数的输入参数
*/
void sys_timer_set_user_data(u16 id, void *priv);
/**
* @brief 获取ms级定时任务处理函数的输入参数的值。
*
* @param [in] id 要获取处理函数的输入参数值的任务ID
*
* @return 返回add时的私有参数
*
* @note
* 1、如果有通过sys_timer_set_user_data重新设置私有参数,
* 则返回的是设置后的私有参数。
*/
void *sys_timer_get_user_data(u16 id);
/*-----------------------------------------------------------*/
/*
* System Usec Timer
*/
int sys_timer_modify(u16 id, u32 msec);
int sys_usec_timer_add(void *priv, void (*func)(void *priv), u32 usec);
void sys_usec_timer_schedule(struct sys_cpu_timer *);
void sys_usec_timer_set(int _t, u32 usec);
void sys_usec_timer_del(int);
void sys_timer_dump_time(void);
u32 sys_timer_get_ms(void);
/*-----------------------------------------------------------*/
/*
* Usr Timer
*/
void usr_timer_schedule();
/**
* @brief usr_timer定时扫描增加接口
*
* @param [in] priv 私有参数
* @param [in] func 定时扫描回调函数
* @param [in] msec 定时时间, 单位:毫秒
* @param [in] priority 优先级范围0/1
*
* @return 定时器分配的id号
*
* @note
* 1、usr_timer的参数priority优先级为1使用该类定时器系统无法进入低功耗
* 2、usr_timer的参数priority优先级为0使用该类定时器系统低功耗会忽略该节拍节拍不会丢失但是定时周期会变
* 3、usr_timer属于异步接口 add的时候注册的扫描函数将在硬件定时器中时基到时候被调用;
* 4、对应释放接口usr_timer_del。
*/
u16 usr_timer_add(void *priv, void (*func)(void *priv), u32 msec, u8 priority);
/**
* @brief usr_timer超时增加接口
*
* @param [in] priv 私有参数
* @param [in] func 超时回调函数
* @param [in] msec 定时时间, 单位:毫秒
* @param [in] priority 优先级,范围0/1
*
* @return 定时器分配的id号
*
* @note
* 1、usr_timerout的参数priority优先级为1使用该类定时器系统无法进入低功耗
* 2、usr_timerout的参数priority优先级为0使用该类定时器系统低功耗会忽略该节拍节拍不会丢失但是定时周期会变
* 3、usr_timerout属于异步接口 add的时候注册的扫描函数将在硬件定时器中时基到时候被调用
* 4、对应释放接口usr_timerout_del
* 5、timeout回调只会被执行一次。
*/
u16 usr_timeout_add(void *priv, void (*func)(void *priv), u32 msec, u8 priority);
/**
* @brief usr_timer修改定时扫描时间接口
*
* @param [in] id usr_timer_add时分配的id号
* @param [in] msec 定时时间,单位:毫秒
*/
int usr_timer_modify(u16 id, u32 msec);
/**
* @brief usr_timerout修改超时时间接口
*
* @param [in] id usr_timerout_add时分配的id号
* @param [in] msec 定时时间,单位:毫秒
*/
int usr_timeout_modify(u16 id, u32 msec);
/**
* @brief usr_timer删除接口
*
* @param [in] id usr_timer_add时分配的id号
*
* @note
* 1、注意与usr_timer_add成对使用。
*/
void usr_timer_del(u16 id);
/**
* @brief usr_timeout删除接口
*
* @param [in] id usr_timerout_add时分配的id号
*
* @note
* 1、注意与usr_timerout_add成对使用。
*/
void usr_timeout_del(u16 id);
/**
* @brief usr_time输出调试信息
*
* @note
* 1.调试时可用;
* 2.将输出所有被add定时器的id及其时间(msec)。
*/
void usr_timer_dump(void);
/*-----------------------------------------------------------*/
/*
* For Compatible
*/
#define sys_hi_timer_schedule()\
usr_timer_schedule()
#define sys_hi_timer_add(a, b, c)\
usr_timer_add(a, b, c, 1)
#define sys_hi_timeout_add(a, b, c)\
usr_timeout_add(a, b, c, 1)
#define sys_hi_timer_modify(a, b)\
usr_timer_modify(a, b)
#define sys_hi_timeout_modify(a, b)\
usr_timeout_modify(a, b)
#define sys_hi_timer_del(a)\
usr_timer_del(a)
#define sys_hi_timeout_del(a)\
usr_timeout_del(a)
#define sys_s_hi_timer_add(a, b, c)\
usr_timer_add(a, b, c, 0)
#define sys_s_hi_timerout_add(a, b, c)\
usr_timeout_add(a, b, c, 0)
#define sys_s_hi_timer_modify(a, b)\
usr_timer_modify(a, b)
#define sys_s_hi_timeout_modify(a, b)\
usr_timeout_modify(a, b)
#define sys_s_hi_timer_del(a)\
usr_timer_del(a)
#define sys_s_hi_timeout_del(a)\
usr_timeout_del(a)
#endif

View File

@ -0,0 +1,115 @@
#ifndef __FONT_ALL_H__
#define __FONT_ALL_H__
#include "generic/typedef.h"
#include "font/font_sdfs.h"
typedef struct {
u8 width;
u8 size;
u16 addr;
} ASCSTRUCT;
//标志位
#define FONT_GET_WIDTH 0x01
#define FONT_SHOW_PIXEL 0x02
#define FONT_SHOW_MULTI_LINE 0x04 /* 显示多行文本(默认显示一行) */
#define FONT_SHOW_SCROLL 0x08 /* 滚动显示*/
#define FONT_HIGHLIGHT_SCROLL 0x10 /* 高亮滚动显示*/
#define FONT_SHOW_SCROLL_RESET 0x40 /* 滚动复位*/
#define FONT_DEFAULT (FONT_SHOW_PIXEL)
#define FONT_ENCODE_ANSI 0x00
#define FONT_ENCODE_UNICODE 0x01
#define FONT_ENCODE_UTF8 0x02
#define FONT_ENDIAN_BIG 0x00
#define FONT_ENDIAN_SMALL 0x01
struct font_file {
char *name;
FILE *fd;
};
struct font {
struct font_file file;
u16 nbytes;
u8 size;
u8 *pixelbuf;
};
struct dispbuf {
int format;
u32 color;
void *rect;
void *map;
};
enum FONT_STATUS {
FT_ERROR_NONE,
FT_ERROR_NOPIXFILE = 0x01, //没有字模文件
FT_ERROR_NOASCPIXFILE = 0x02, //没有ASCII字模文件
FT_ERROR_NOTABFILE = 0x04, //没有TAB文件
FT_ERROR_NOMEM = 0x08, //内存不足
FT_ERROR_CODEPAGE = 0x10, //代码页错误
};
struct font_info {
struct font ascpixel; //ASCII像素
struct font pixel; //像素
struct font_file tabfile; //UNICODE转内码文件
struct font_file extfile;
u8 sta; //状态
u8 ratio; //放大倍数,默认为1
u8 language_id; //语言ID
u8 bigendian; //大端模式(unicode编码)
u8 isgb2312; //是否GB2312,用以区分GBK以及GB2312字库
u8 codepage; //代码页
u16 x;
u16 y;
u16 text_width; //文本宽度
u16 text_height; //文本高度
u16 string_width; //字符串宽度
u16 string_height; //字符串高度
u16 offset; //显示偏移
u32 flags; //标志位
struct dispbuf disp; //显示相关信息
void (*putchar)(struct font_info *info, u8 *pixel, u16 width, u16 height, u16 x, u16 y);
void *dc;
};
#define font_ntohl(x) (unsigned long)((x>>24)|((x>>8)&0xff00)|(x<<24)|((x&0xff00)<<8))
#define font_ntoh(x) (unsigned short int )((x>>8&0x00ff)|x<<8&0xff00)
extern const struct font_info font_info_table[];
typedef struct {
u8 codepage;
u32 ansi_offset;
u32 table_offset;
} LANG_TABLE;
#define CP874 (1)
#define CP937 (2)
#define CP1250 (3)
#define CP1251 (4)
#define CP1252 (5)
#define CP1253 (6)
#define CP1254 (7)
#define CP1255 (8)
#define CP1256 (9)
#define CP1257 (10)
#define CP1258 (11)
#define CPKSC (12)
#define CPSIJS (13)
extern const LANG_TABLE *lange_info_table;
int font_set_offset_table(const LANG_TABLE *table);
#endif

View File

@ -0,0 +1,23 @@
#ifndef __UI_SDFS_H__
#define __UI_SDFS_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "generic/typedef.h"
#include "fs/fs.h"
#define SD_SEEK_SET 0x00
#define SD_SEEK_CUR 0x01
FILE *font_sd_fopen(const char *filename, void *arg);
int font_sd_fread(FILE *fp, void *buf, u32 len);
int font_sd_fseek(FILE *fp, u8 seek_mode, u32 offset);
int font_sd_fclose(FILE *fp);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,103 @@
#ifndef __FONT_OUT_H__
#define __FONT_OUT_H__
#include "generic/typedef.h"
#include "font/font_all.h"
/**
* @brief 打开字库
*
* @param info:字库信息
* @param language:语言
*
* @returns TRUE:打开成功 FALSE:打开失败
*/
struct font_info *font_open(struct font_info *info, u8 language);
/**
* @brief 获取字符宽度
*
* @param info
* @param str
* @param strlen
*
* @returns
*/
u16 font_text_width(struct font_info *info, u8 *str, u16 strlen);
u16 font_textw_width(struct font_info *info, u8 *str, u16 strlen);
u16 font_textu_width(struct font_info *info, u8 *str, u16 strlen);
/**
* @brief 字库内码显示接口
*
* @param info
* @param str
* @param strlen
*
* @returns
*/
u16 font_textout(struct font_info *info, u8 *str, u16 strlen, u16 x, u16 y);
/**
* @brief 字库unicode显示接口
*
* @param info
* @param str
* @param strlen
* @param x
* @param y
*
* @returns
*/
u16 font_textout_unicode(struct font_info *info, u8 *str, u16 strlen, u16 x, u16 y);
/**
* @brief 字库utf8显示接口
*
* @param info
* @param str
* @param strlen
* @param x
* @param y
*
* @returns
*/
u16 font_textout_utf8(struct font_info *info, u8 *str, u16 strlen, u16 x, u16 y);
/**
* @brief utf8转内码
*
* @param info
* @param utf8
* @param utf8len
* @param ansi
*
* @returns
*/
u16 font_utf8toansi(struct font_info *info, u8 *utf8, u16 utf8len, u8 *ansi);
/**
* @brief utf16转内码
*
* @param info
* @param utf
* @param len
* @param ansi
*
* @returns
*/
u16 font_utf16toansi(struct font_info *info, u8 *utf, u16 len, u8 *ansi);
/**
* @brief utf8转utf16
*
* @param info
* @param utf8
* @param utf8len
* @param utf16
*
* @returns
*/
u16 font_utf8toutf16(struct font_info *info, u8 *utf8, u16 utf8len, u16 *utf16);
/**
* @brief 字库关闭
*
* @param info
*/
void font_close(struct font_info *info);
#endif

View File

@ -0,0 +1,29 @@
#ifndef __LANGUAGE_LIST_H__
#define __LANGUAGE_LIST_H__
#define Chinese_Simplified 1 //简体中文
#define Chinese_Traditional 2 //繁体中文
#define Japanese 3 //日语
#define Korean 4 //韩语
#define English 5 //英语
#define French 6 //法语
#define German 7 //德语
#define Italian 8 //意大利语
#define Dutch 9 //荷兰语
#define Portuguese 10 //葡萄牙语
#define Spanish 11 //西班牙语
#define Swedish 12 //瑞典语
#define Czech 13 //捷克语
#define Danish 14 //丹麦语
#define Polish 15 //波兰语
#define Russian 16 //俄语
#define Turkey 17 //土耳其语
#define Hebrew 18 //希伯来语
#define Thai 19 //泰语
#define Hungarian 20 //匈牙利语
#define Romanian 21 //罗马尼亚语
#define Arabic 22 //阿拉伯语
#define Vietnam 23 //越南语
#define Tibetan 24 //藏文
#endif

View File

@ -0,0 +1,101 @@
#ifndef RESFILE_H
#define RESFILE_H
#include "typedef.h"
#include "fs/fs.h"
// resfile共用文件句柄
#if (defined(CONFIG_CPU_BR23) && defined(CONFIG_APP_WATCH))
#define RESFILE_COMMON_HDL_EN 0
#else
#define RESFILE_COMMON_HDL_EN 0
#endif
#define FILE_TYPE_JPEG 5
#define AT_UI_RAM AT(.ui_ram)
//图像数据格式
enum {
PIXEL_FMT_ARGB8888,
PIXEL_FMT_RGB888,
PIXEL_FMT_RGB565,
PIXEL_FMT_L8,
PIXEL_FMT_AL88,
PIXEL_FMT_AL44,
PIXEL_FMT_A8,
PIXEL_FMT_L1,
PIXEL_FMT_ARGB8565,
PIXEL_FMT_OSD16,
PIXEL_FMT_SOLID,
PIXEL_FMT_JPEG,
PIXEL_FMT_UNKNOW,
};
// #define EXTERN_PATH "storage/nor_ui/C/res/"
// #define EXTERN_PATH "storage/virfat_flash/C/uires/"
struct image_file {
u8 format;
u8 compress;
u16 data_crc;
u16 width;
u16 height;
u32 offset;
u32 len;
};
typedef struct resfile {
FILE *file;
#if RESFILE_COMMON_HDL_EN
struct list_head entry;
u32 offset;
u32 size;
#endif
} RESFILE;
int open_resfile(const char *name);
void close_resfile();
int res_file_version_compare(int res_ver);
int open_str_file(const char *name);
void close_str_file();
int str_file_version_compare(int str_ver);
int open_style_file(const char *name);
int font_ascii_init(const char *name);
int open_image_by_id(RESFILE *specfile, struct image_file *f, int id, int page);
int read_image_data(struct image_file *f, u8 *data, int len);
int br23_read_image_data(RESFILE *specfile, struct image_file *f, u8 *data, int len, int offset);
int br25_read_image_data(RESFILE *specfile, struct image_file *f, u8 *data, int len, int offset);
u32 image_decode(const void *pSour, void *pDest, u32 SourLen, u32 DestLen, u8 compress);
int open_string_pic(struct image_file *file, int id);
int read_str_data(struct image_file *f, u8 *data, int len);
int br23_read_str_data(struct image_file *f, u8 *data, int len, int offset);
int br25_read_str_data(struct image_file *f, u8 *data, int len, int offset);
int load_pallet_table(int id, u32 *data);
int ui_language_set(int language);
int ui_language_get();
RESFILE *res_fopen(const char *path, const char *mode);
int res_fread(RESFILE *_file, void *buf, u32 len);
int res_fseek(RESFILE *_file, int offset, int fromwhere);
int res_flen(RESFILE *file);
int res_fclose(RESFILE *file);
int _norflash_read_watch(u8 *buf, u32 addr, u32 len, u8 wait);//加速读
struct ui_load_info {
u8 pj_id;
const char *path;
RESFILE *file;
RESFILE *res;
RESFILE *str;
};
void *ui_load_res_by_pj_id(int pj_id);
void *ui_load_str_by_pj_id(int pj_id);
int ui_set_sty_path_by_pj_id(int pj_id, const u8 *path);
void *ui_load_sty_by_pj_id(int pj_id);
#endif

View File

@ -0,0 +1,371 @@
#ifndef UI_CONTROL_H
#define UI_CONTROL_H
#include "ui/ui_core.h"
union ui_control_info;
struct layout_info;
#define CTRL_TYPE_WINDOW 2
#define CTRL_TYPE_LAYOUT 3
#define CTRL_TYPE_LAYER 4
#define CTRL_TYPE_GRID 5
#define CTRL_TYPE_LIST 6
#define CTRL_TYPE_BUTTON 7
#define CTRL_TYPE_PIC 8
#define CTRL_TYPE_BATTERY 9
#define CTRL_TYPE_TIME 10
#define CTRL_TYPE_CAMERA_VIEW 11
#define CTRL_TYPE_TEXT 12
#define CTRL_TYPE_ANIMATION 13
#define CTRL_TYPE_PLAYER 14
#define CTRL_TYPE_NUMBER 15
#define CTRL_TYPE_PROGRESS 20
#define CTRL_PROGRESS_CHILD_BEGIN (CTRL_TYPE_PROGRESS + 1)
#define CTRL_PROGRESS_CHILD_HIGHLIGHT (CTRL_PROGRESS_CHILD_BEGIN) //21
#define CTRL_PROGRESS_CHILD_END (CTRL_PROGRESS_CHILD_BEGIN + 1)
#define CTRL_TYPE_MULTIPROGRESS 22
#define CTRL_MULTIPROGRESS_CHILD_BEGIN (CTRL_TYPE_MULTIPROGRESS + 1)
#define CTRL_MULTIPROGRESS_CHILD_HIGHLIGHT (CTRL_MULTIPROGRESS_CHILD_BEGIN)//23
#define CTRL_MULTIPROGRESS_CHILD_END (CTRL_MULTIPROGRESS_CHILD_BEGIN + 1)
#define CTRL_TYPE_WATCH 24
#define CTRL_WATCH_CHILD_BEGIN (CTRL_TYPE_WATCH + 1)
#define CTRL_WATCH_CHILD_HOUR (CTRL_WATCH_CHILD_BEGIN)//25
#define CTRL_WATCH_CHILD_MIN (CTRL_WATCH_CHILD_BEGIN+1)//26
#define CTRL_WATCH_CHILD_SEC (CTRL_WATCH_CHILD_BEGIN+2)//27
#define CTRL_WATCH_CHILD_END (CTRL_WATCH_CHILD_BEGIN+3)
#define CTRL_TYPE_SLIDER 28
#define SLIDER_CHILD_BEGIN (CTRL_TYPE_SLIDER+1)
#define SLIDER_CHILD_UNSELECT_PIC (SLIDER_CHILD_BEGIN)//29
#define SLIDER_CHILD_SELECTED_PIC (SLIDER_CHILD_BEGIN+1)//30
#define SLIDER_CHILD_SLIDER_PIC (SLIDER_CHILD_BEGIN+2)//31
#define SLIDER_CHILD_PERSENT_TEXT (SLIDER_CHILD_BEGIN+3)//32
#define SLIDER_CHILD_END (SLIDER_CHILD_BEGIN+4)
#define CTRL_TYPE_VSLIDER 33
#define VSLIDER_CHILD_BEGIN (CTRL_TYPE_VSLIDER+1)
#define VSLIDER_CHILD_UNSELECT_PIC (VSLIDER_CHILD_BEGIN)//34
#define VSLIDER_CHILD_SELECTED_PIC (VSLIDER_CHILD_BEGIN+1)//35
#define VSLIDER_CHILD_SLIDER_PIC (VSLIDER_CHILD_BEGIN+2)//36
#define VSLIDER_CHILD_PERSENT_TEXT (VSLIDER_CHILD_BEGIN+3)//37
#define VSLIDER_CHILD_END (VSLIDER_CHILD_BEGIN+4)
struct ui_ctrl_info_head {
u8 type;
u8 ctrl_num;
u8 css_num;
u8 len;
u8 page;
u8 rev[3];
int id;
struct element_css1 *css;
};
struct ui_image_list {
u16 num;
u16 image[0];
};
struct ui_text_list {
u16 num;
char str[0];
};
struct ui_image_list_t {
u16 num;
u16 image[64];
};
#define UI_TEXT_LIST_MAX_NUM 3
struct ui_text_list_t {
u16 num;
u16 str[50];
};
struct ui_button_info {
struct ui_ctrl_info_head head;
struct element_event_action *action;
};
struct ui_camera_info {
struct ui_ctrl_info_head head;
char device[8];
struct element_event_action *action;
};
struct ui_player_info {
struct ui_ctrl_info_head head;
char device[8];
struct element_event_action *action;
};
struct ui_time_info {
struct ui_ctrl_info_head head;
char source[8];
u8 auto_cnt;
u8 rev[3];
char format[16];
int color;
int hi_color;
u16 number[10];
u16 delimiter[10];
struct element_event_action *action;
};
struct ui_number_info {
struct ui_ctrl_info_head head;
char source[8];
char format[16];
int color;
int hi_color;
u16 number[10];
u16 delimiter[10];
u16 space[2];
struct element_event_action *action;
};
struct ui_pic_info {
struct ui_ctrl_info_head head;
u8 highlight;
u16 cent_x;
u16 cent_y;
struct ui_image_list *normal_img;
struct ui_image_list *highlight_img;
struct element_event_action *action;
};
struct ui_battery_info {
struct ui_ctrl_info_head head;
struct ui_image_list *normal_image;
struct ui_image_list *charge_image;
struct element_event_action *action;
};
struct ui_text_info {
struct ui_ctrl_info_head head;
char source[8];
char code[8];
int color;
int highlight_color;
struct ui_text_list *str;
struct element_event_action *action;
};
struct ui_grid_info {
struct ui_ctrl_info_head head;
u8 page_mode;
char highlight_index;
struct element_event_action *action;
struct layout_info *info;
};
struct ui_animation_info {
struct ui_ctrl_info_head head;
u16 loop_num;
u32 interval;
struct ui_image_list *img;
struct element_event_action *action;
};
struct ui_slider_info {
struct ui_ctrl_info_head head;
u8 step;
struct ui_ctrl_info_head *ctrl;
// struct element_event_action *action;
};
struct ui_vslider_info {
struct ui_ctrl_info_head head;
u8 step;
struct ui_ctrl_info_head *ctrl;
// struct element_event_action *action;
};
struct ui_watch_info {
struct ui_ctrl_info_head head;
char source[8];
struct element_event_action *action;
struct ui_ctrl_info_head *ctrl;
};
struct ui_progress_info {
struct ui_ctrl_info_head head;
char source[8];
struct element_event_action *action;
struct ui_ctrl_info_head *ctrl;
};
struct ui_multiprogress_info {
struct ui_ctrl_info_head head;
char source[8];
struct element_event_action *action;
struct ui_ctrl_info_head *ctrl;
};
struct ui_browser_info {
struct ui_ctrl_info_head head;
u8 row;
u8 column;
u8 interval;
u8 scroll;
u8 auto_highlight;
struct element_event_action *action;
struct ui_ctrl_info_head *ctrl;
};
struct ui_fattrs_info {
struct ui_ctrl_info_head head;
struct element_event_action *action;
struct ui_ctrl_info_head *ctrl;
};
struct layout_info {
struct ui_ctrl_info_head head;
struct element_event_action *action;
union ui_control_info *ctrl;
};
struct layer_info {
struct ui_ctrl_info_head head;
u8 format;
struct element_event_action *action;
struct layout_info *layout;
};
union ui_control_info {
struct ui_ctrl_info_head head;//16 bytes
struct ui_button_info button;//20 bytes
struct ui_camera_info camera;//28 bytes
struct ui_time_info time;//84 bytes
struct ui_number_info number;
struct ui_pic_info pic;//36 bytes
struct ui_battery_info battery;//28 bytes
struct ui_text_info text;//40 bytes
struct ui_grid_info grid;//28 bytes
struct layer_info layer;
struct layout_info layout;
struct ui_watch_info watch;
struct ui_progress_info progress;
struct ui_multiprogress_info multiprogress;
struct ui_slider_info slider;
struct ui_vslider_info vslider;
};//84 bytes
// union ui_control_info {
// struct ui_ctrl_info_head head;
// struct ui_button_info button;
// struct ui_camera_info camera;
// struct ui_time_info time;
// struct ui_number_info number;
// struct ui_pic_info pic;
// struct ui_battery_info battery;
// struct ui_text_info text;
// struct ui_grid_info grid;
// };
struct window_info {
u8 type;
u8 ctrl_num;
u8 css_num;
u8 len;
u8 rev[4];
struct rect rect;
struct layer_info *layer;
// struct element_event_action *action;
};
struct control_ops {
int type;
void *(*new)(const void *, struct element *);
/*int (*delete)(void *);*/
};
extern const struct control_ops control_ops_begin[];
extern const struct control_ops control_ops_end[];
#define REGISTER_CONTROL_OPS(_type) \
static const struct control_ops control_ops_##_type sec(.control_ops) __attribute__((used)) = { \
.type = _type,
#define get_control_ops_by_type(_type) \
({ \
const struct control_ops *ops, *ret=NULL; \
for (ops = control_ops_begin; ops < control_ops_end; ops++) { \
if (ops->type == _type) { \
ret = ops; \
break; \
} \
}\
ret; \
})
#if 0
struct control_event_header {
int id;
int len;
};
extern struct control_event_header control_event_handler_begin[];
extern struct control_event_header control_event_handler_end[];
#define REGISTER_CONTROL_EVENT_HANDLER(control, _id) \
static const struct control##_event_handler __##control##_event_handler_##_id \
sec(.control_event_handler) = { \
.header = { \
.id = _id, \
.len = sizeof(struct control##_event_handler), \
}, \
static inline void *control_event_handler_for_id(int id)
{
struct control_event_header *p;
for (p = control_event_handler_begin; p < control_event_handler_end;) {
if (p->id == id) {
return p;
}
p = (u8 *)p + p->len;
}
return NULL;
}
#endif
#endif

View File

@ -0,0 +1,53 @@
#ifndef LAYER_H
#define LAYER_H
#include "ui/layout.h"
#include "ui/control.h"
struct layer {
struct element elm; //must be first
u8 hide;
u8 inited;
u8 highlight;
u8 ctrl_num;
u8 css_num;
u32 css[2];
struct draw_context dc;
struct layout *layout;
const struct layer_info *info;
const struct element_event_handler *handler;
};
#define layer_for_id(id) \
(struct layer *)ui_core_get_element_by_id(id);
struct layer *layer_new(struct layer_info *info, int num, struct element *parent);
void layer_delete_probe(struct layer *layer, int num);
void layer_delete(struct layer *layer, int num);
int layer_show(int id);
int layer_hide(int id);
int layer_toggle(int id);
#endif

View File

@ -0,0 +1,54 @@
#ifndef LAYOUT_H
#define LAYOUT_H
#include "ui/ui_core.h"
#include "ui/control.h"
struct layout {
struct element elm; //must be first
u8 hide: 1;
u8 inited: 1;
u8 release: 6;
// u8 css_num:5;
// u32 css[2];
struct layout *layout;
const struct layout_info *info;
const struct element_event_handler *handler;
};
#define layout_for_id(id) \
(struct layout *)ui_core_get_element_by_id(id);
struct layout *layout_new(struct layout_info *, int, struct element *);
void layout_delete_probe(struct layout *layout, int num);
void layout_delete(struct layout *layout, int num);
int layout_show(int id);
int layout_hide(int id);
int layout_toggle(int id);
void layout_on_focus(struct layout *layout);
void layout_lose_focus(struct layout *layout);
/*int layout_current_highlight(int id);*/
/*int layout_onkey(struct layout *layout, struct element_key_event *e);*/
#endif

View File

@ -0,0 +1,40 @@
#ifndef UI_P_H
#define UI_P_H
#include "ui/ui_core.h"
struct ui_str {
const char *format;
char *str;
};
struct element_text {
struct element elm; //must be first
char *str;
const char *format;
void *priv;
int color;
const struct element_event_handler *handler;
};
void text_element_set_text(struct element_text *text, char *str,
const char *format, int color);
void text_element_init(struct element_text *text, int id, u8 page, u8 prj,
const struct element_css1 *css,
const struct element_event_action *action);
void text_element_set_event_handler(struct element_text *text, void *priv,
const struct element_event_handler *handler);
#endif

View File

@ -0,0 +1,112 @@
#ifndef UI_CORE_H
#define UI_CORE_H
#include "window.h"
#include "ui_button.h"
#include "ui_grid.h"
#include "ui_time.h"
#include "ui_camera.h"
#include "ui_pic.h"
#include "ui_text.h"
#include "ui_battery.h"
#include "ui_browser.h"
#include "ui_slider.h"
#include "ui_slider_vert.h"
#include "ui_number.h"
#include "ui_watch.h"
#include "ui_progress.h"
#include "ui_progress_multi.h"
#include "ui_rotate.h"
#include <stdarg.h>
struct uimsg_handl {
const char *msg;
int (*handler)(const char *type, u32 args);
};
int ui_framework_init(void *);
int ui_set_style_file(struct ui_style *style);
int ui_style_file_version_compare(int version);
int ui_redraw(int id);
int ui_show(int id);
int ui_hide(int id);
int ui_set_call(int (*func)(int), int param);
int ui_event_onkey(struct element_key_event *e);
int ui_event_ontouch(struct element_touch_event *e);
struct element *ui_get_highlight_child_by_id(int id);
int ui_invert_element_by_id(int id);
int ui_no_highlight_element(struct element *elm);
int ui_no_highlight_element_by_id(int id);
int ui_highlight_element(struct element *elm);
int ui_highlight_element_by_id(int id);
int ui_get_current_window_id();
int ui_register_msg_handler(int id, const struct uimsg_handl *handl);
int ui_message_handler(int id, const char *msg, va_list);
const char *str_substr_iter(const char *str, char delim, int *iter);
int ui_get_child_by_id(int id, int (*event_handler_cb)(void *, int, int));
int ui_set_default_handler(int (*ontouch)(void *, struct element_touch_event *),
int (*onkey)(void *, struct element_key_event *),
int (*onchange)(void *, enum element_change_event, void *));
/*
* 锁定元素elm之外的区域所有的触摸消息都发给elm
*/
void ui_ontouch_lock(void *elm);
void ui_ontouch_unlock(void *elm);
/*
* 锁定控件的夫图层先不推向imb显示
*/
int ui_lock_layer(int id);
int ui_unlock_layer(int id);
int ui_get_disp_status_by_id(int id);
int create_control_by_id(char *tabfile, int page_id, int id, int parent_id);
int delete_control_by_id(int id);
void ui_remove_backcolor(struct element *elm);
void ui_remove_backimage(struct element *elm);
void ui_remove_border(struct element *elm);
int ui_fill_rect(struct draw_context *dc, int left, int top, int width, int height, u32 acolor);
int ui_draw_image(struct draw_context *dc, int page, int id, int x, int y);
int ui_draw_ascii(struct draw_context *dc, char *str, int strlen, int x, int y, int color);
int ui_draw_text(struct draw_context *dc, int encode, int endian, char *str, int strlen, int x, int y, int color);
int ui_draw_strpic(struct draw_context *dc, int id, int x, int y, int color);
void ui_draw_line(void *_dc, int x0, int y0, int x1, int y1, int color);
void ui_draw_line_by_angle(void *_dc, int x, int y, int length, int angle, int color);
void ui_draw_rect(void *_dc, int x, int y, int width, int height, int color);
void ui_draw_circle(struct draw_context *dc, int center_x, int center_y,
int radius_big, int radius_small, int angle_begin,
int angle_end, int color, int percent);
int ui_draw_set_pixel(struct draw_context *dc, int x, int y, int pixel);
u32 ui_draw_get_pixel(struct draw_context *dc, int x, int y);
u16 ui_draw_get_mixed_pixel(u16 backcolor, u16 forecolor, u8 alpha);
void *load_control_info_by_id(char *tabfile, u32 page_id, u32 id);
void *ui_control_new(void *_pos, void *parent);
#define ui_id2type(id) (((id)>>16) & 0x3f)
#endif

View File

@ -0,0 +1,37 @@
lcd_interface_begin = .;
KEEP(*(.lcd_if_info))
lcd_interface_end = .;
ui_style_begin = .;
KEEP(*(.ui_style))
ui_style_end = .;
elm_event_handler_begin_JL = .;
KEEP(*(.elm_event_handler_JL))
elm_event_handler_end_JL = .;
elm_event_handler_begin_UPGRADE = .;
KEEP(*(.elm_event_handler_UPGRADE))
elm_event_handler_end_UPGRADE = .;
elm_event_handler_begin_DIAL = .;
KEEP(*(.elm_event_handler_DIAL))
elm_event_handler_end_DIAL = .;
control_event_handler_begin = .;
KEEP(*(.control_event_handler))
control_event_handler_end = .;
control_ops_begin = .;
KEEP(*(.control_ops))
control_ops_end = .;
battery_notify_begin = .;
*(.battery_notify)
battery_notify_end = .;

View File

@ -0,0 +1,29 @@
#ifndef UI_BATTERY_H
#define UI_BATTERY_H
#include "ui/control.h"
#include "list.h"
struct ui_battery {
struct element elm;
int src;
u8 index;
u16 charge_image;
u16 normal_image;
struct list_head entry;
const struct ui_battery_info *info;
const struct element_event_handler *handler;
};
void ui_battery_enable();
void ui_battery_level_change(int persent, int incharge);//改变所有电池控件
int ui_battery_set_level_by_id(int id, int persent, int incharge);//修改指定id
int ui_battery_set_level(struct ui_battery *battery, int persent, int incharge);//初始化使用
#endif

View File

@ -0,0 +1,92 @@
#ifndef UI_BROWSER_H
#define UI_BROWSER_H
#include "ui/ui_core.h"
#include "ui/control.h"
struct ui_browser {
struct element elm;
struct ui_file_browser *hdl;
char order; // 1 表示 正序, 非1 表示反序
u8 inited;
u8 hide_byself;
u8 item_num;
u8 highlight;
u8 show_mode;
u16 cur_number;
u16 file_number;
struct ui_grid *grid;
const char *path;
const char *ftype;
const struct ui_browser_info *info;
const struct element_event_handler *handler;
};
#define ui_file_browser_cur_item(bro) ui_grid_cur_item(((struct ui_browser *)bro)->grid)
int ui_file_browser_page_num(struct ui_browser *bro);
int ui_file_browser_cur_page(struct ui_browser *bro, int *file_num);
int ui_file_browser_set_page(struct ui_browser *bro, int page);
int ui_file_browser_set_page_by_id(int id, int page);
int ui_file_browser_next_page(struct ui_browser *bro);
int ui_file_browser_next_page_by_id(int id);
int ui_file_browser_prev_page(struct ui_browser *bro);
int ui_file_browser_prev_page_by_id(int id);
int ui_file_browser_set_dir(struct ui_browser *bro, const char *path, const char *ftype);
int ui_file_browser_set_dir_by_id(int id, const char *path, const char *ftype);
int ui_file_browser_get_file_attrs(struct ui_browser *bro, int item,
struct ui_file_attrs *attrs);
int ui_file_browser_set_file_attrs(struct ui_browser *bro, int item,
struct ui_file_attrs *attrs);
void *ui_file_browser_open_file(struct ui_browser *bro, int item);
int ui_file_browser_del_file(struct ui_browser *bro, int item);
int ui_file_browser_highlight_item(struct ui_browser *bro, int item, bool yes);
void *ui_file_browser_get_child_by_id(struct ui_browser *bro, int item, int id);
#endif

View File

@ -0,0 +1,20 @@
#ifndef UI_BUTTON_H
#define UI_BUTTON_H
#include "ui/control.h"
#include "ui/ui_core.h"
struct button {
struct element elm;
u8 image_index;
u8 css_num;
u32 css[2];
const struct ui_button_info *info;
const struct element_event_handler *handler;
};
void ui_button_enable();
#endif

View File

@ -0,0 +1,34 @@
#ifndef UI_CAMERA_H
#define UI_CAMERA_H
#include "ui/control.h"
#include "ui/ui_core.h"
struct ui_camera {
struct element elm; //must be first
int fd;
const struct ui_camera_info *info;
const struct element_event_handler *handler;
};
#define ui_camera_for_id(id) \
(struct ui_camera*)ui_core_get_element_by_id(id)
void register_ui_camera_handler(const struct element_event_handler *handler);
int ui_camera_set_rect(int id, struct rect *r);
#endif

View File

@ -0,0 +1,566 @@
#ifndef UI_ELEMENT_CORE_H
#define UI_ELEMENT_CORE_H
#include "typedef.h"
#include "rect.h"
#include "system/event.h"
// #include "fs/fs.h"
#include "res/resfile.h"
#define UI_CTRL_BUTTON 0
struct element;
#ifdef offsetof
#undef offsetof
#endif
#ifdef container_of
#undef container_of
#endif
#define offsetof(type, memb) \
((unsigned long)(&((type *)0)->memb))
#define container_of(ptr, type, memb) \
((type *)((char *)ptr - offsetof(type, memb)))
enum ui_direction {
UI_DIR_UP,
UI_DIR_DOWN,
UI_DIR_LEFT,
UI_DIR_RIGHT,
};
enum ui_align {
UI_ALIGN_LEFT = 0,
UI_ALIGN_CENTER,
UI_ALIGN_RIGHT,
};
enum {
POSITION_ABSOLUTE = 0,
POSITION_RELATIVE = 1,
};
enum {
ELM_EVENT_TOUCH_DOWN,
ELM_EVENT_TOUCH_MOVE,
ELM_EVENT_TOUCH_R_MOVE,
ELM_EVENT_TOUCH_L_MOVE,
ELM_EVENT_TOUCH_D_MOVE,
ELM_EVENT_TOUCH_U_MOVE,
ELM_EVENT_TOUCH_HOLD,
ELM_EVENT_TOUCH_UP,
};
enum {
ELM_EVENT_KEY_CLICK,
ELM_EVENT_KEY_LONG,
ELM_EVENT_KEY_HOLD,
};
enum {
ELM_STA_INITED,
//ELM_STA_SHOW_PROBE,
//ELM_STA_SHOW_POST,
ELM_STA_HIDE,
ELM_STA_SHOW,
ELM_STA_PAUSE,
};
enum {
ELM_FLAG_NORMAL,
ELM_FLAG_HEAD,
};
enum {
DC_DATA_FORMAT_OSD8 = 0,
DC_DATA_FORMAT_YUV420 = 1,
DC_DATA_FORMAT_OSD16 = 2,
DC_DATA_FORMAT_OSD8A = 3,
DC_DATA_FORMAT_MONO = 4,
};
struct element_touch_event {
int event;
int xoffset;
int yoffset;
u8 hold_up;
u8 onfocus;
u8 move_dir;
struct position pos;
struct position mov;
void *private_data;
};
struct element_key_event {
u8 event;
u8 value;
void *private_data;
};
#define ELM_KEY_EVENT(e) (0x0000 | (e->event) | (e->value << 8))
#define ELM_TOUCH_EVENT(e) (0x1000 | (e->event))
#define ELM_CHANGE_EVENT(e) (0x2000 | (e->event))
enum element_change_event {
ON_CHANGE_INIT_PROBE,
ON_CHANGE_INIT,
ON_CHANGE_TRY_OPEN_DC,
ON_CHANGE_FIRST_SHOW,
ON_CHANGE_SHOW_PROBE,
ON_CHANGE_SHOW,
ON_CHANGE_SHOW_POST,
ON_CHANGE_HIDE,
ON_CHANGE_HIGHLIGHT,
ON_CHANGE_RELEASE_PROBE,
ON_CHANGE_RELEASE,
ON_CHANGE_ANIMATION_END,
ON_CHANGE_SHOW_COMPLETED,
ON_CHANGE_UPDATE_ITEM,
};
struct element_event_handler {
int id;
int (*ontouch)(void *, struct element_touch_event *);
int (*onkey)(void *, struct element_key_event *);
int (*onchange)(void *, enum element_change_event, void *);
};
struct jaction {
u32 show;
u32 hide;
};
enum {
ELM_ACTION_HIDE = 0,
ELM_ACTION_SHOW,
ELM_ACTION_TOGGLE,
ELM_ACTION_HIGHLIGHT,
};
struct event_action {
u16 event;
u16 action;
int id;
u8 argc;
char argv[];
};
struct element_event_action {
u16 num;
struct event_action action[0];
};
struct image_preview {
RESFILE *file;
int id;
int page;
};
struct image {
int x;
int y;
int id;
int page;
int en;
};
struct draw_context {
u8 ref;
u8 alpha;
u8 align;
u8 data_format;
u8 prj;
u8 page;
u8 buf_num;
u32 background_color;
void *handl;
struct element *elm;
struct rect rect;
struct rect draw;
void *dc;
struct image_preview preview;
struct rect need_draw;
struct rect disp;
u16 width;
u16 height;
u8 *fbuf;
u32 fbuf_len;
u8 *buf;
u8 *buf0;
u8 *buf1;
u32 len;
u16 lines;
u8 col_align;
u8 row_align;
struct image draw_img;
u8 *mask;
};
struct css_border {
u16 left: 4;
u16 top: 4;
u16 right: 4;
u16 bottom: 4;
u16 color: 16;
};
struct css_border1 {
u8 left;
u8 top;
u8 right;
u8 bottom;
int color: 24;
};
struct element_css {
u8 align: 2;
u8 invisible: 1;
u8 z_order: 5;
int left/* : 16 */;
int top/* : 16 */;
int width/* : 16 */;
int height/* : 16 */;
u32 background_color: 24;
u32 alpha: 8;
int background_image: 24;
int image_quadrant: 8;
struct css_border border;
};
struct element_css1 {
u8 align;
u8 invisible;
u8 z_order;
int left;
int top;
int width;
int height;
u32 background_color: 24;
u32 alpha: 8;
int background_image: 24;
int image_quadrant: 8;
struct css_border1 border;
};
struct element_ops {
int (*show)(struct element *);
int (*redraw)(struct element *, struct rect *);
};
struct element {
u32 highlight: 1;
u32 state: 2;
u32 ref: 5;
u32 prj: 3;
u32 page: 21;
// u32 alive;
int id;
struct element *parent;
struct list_head sibling;
struct list_head child;
struct element *focus;
struct element_css css;
struct draw_context *dc;
// const struct element_ops *ops;
const struct element_event_handler *handler;
// const struct element_event_action *action;
};
struct ui_style {
const char *file;
u32 version;
};
enum {
UI_FTYPE_VIDEO = 0,
UI_FTYPE_IMAGE,
UI_FTYPE_AUDIO,
UI_FTYPE_DIR,
UI_FTYPE_UNKNOW = 0xff,
};
struct ui_file_attrs {
char *format;
char fname[128];
struct vfs_attr attr;
u8 ftype;
u16 file_num;
u32 film_len;
};
struct ui_image_attrs {
u16 width;
u16 height;
};
struct ui_text_attrs {
const char *str;
const char *format;
int color;
u16 strlen;
u16 offset;
u8 encode: 2;
u8 endian: 1;
u8 flags: 5;
// u16 offset;
u16 displen;
};
struct ui_file_browser {
int file_number;
u8 dev_num;
void *private_data;
};
#define ELEMENT_ALIVE 0x53547a7b
#define element_born(elm) \
elm->alive = ELEMENT_ALIVE
#define element_alive(elm) \
(elm->alive == ELEMENT_ALIVE)
#define list_for_each_child_element(p, elm) \
list_for_each_entry(p, &(elm)->child, sibling)
#define list_for_each_child_element_reverse(p, n, elm) \
list_for_each_entry_reverse_safe(p, n, &(elm)->child, sibling)
#define list_for_each_child_element_safe(p, n, elm) \
list_for_each_entry_safe(p, n, &(elm)->child, sibling)
struct ui_platform_api {
void *(*malloc)(int);
void (*free)(void *);
int (*load_style)(struct ui_style *);
void *(*load_window)(int id);
void (*unload_window)(void *);
int (*open_draw_context)(struct draw_context *);
int (*get_draw_context)(struct draw_context *);
int (*put_draw_context)(struct draw_context *);
int (*set_draw_context)(struct draw_context *);
int (*close_draw_context)(struct draw_context *);
int (*fill_rect)(struct draw_context *, u32 color);
int (*draw_rect)(struct draw_context *, struct css_border *border);
int (*draw_image)(struct draw_context *, u32 src, u8 quadrant, u8 *mask);
int (*draw_point)(struct draw_context *, u16 x, u16 y, u32 color);
u32(*read_point)(struct draw_context *dc, u16 x, u16 y);
int (*invert_rect)(struct draw_context *, u32 color);
void *(*load_widget_info)(void *_head, u8 page);
void *(*load_css)(u8 page, void *_css);
void *(*load_image_list)(u8 page, void *_list);
void *(*load_text_list)(u8 page, void *__list);
//int (*highlight)(struct draw_context *);
int (*show_text)(struct draw_context *, struct ui_text_attrs *);
int (*read_image_info)(struct draw_context *, u32, u8, struct ui_image_attrs *);
int (*open_device)(struct draw_context *, const char *device);
int (*close_device)(int);
void *(*set_timer)(void *, void (*callback)(void *), u32 msec);
int (*del_timer)(void *);
struct ui_file_browser *(*file_browser_open)(struct rect *r,
const char *path, const char *ftype, int show_mode);
int (*get_file_attrs)(struct ui_file_browser *, struct ui_file_attrs *attrs);
int (*set_file_attrs)(struct ui_file_browser *, struct ui_file_attrs *attrs);
int (*clear_file_preview)(struct ui_file_browser *, struct rect *r);
int (*show_file_preview)(struct ui_file_browser *, struct rect *r, struct ui_file_attrs *attrs);
int (*flush_file_preview)(struct ui_file_browser *);
void *(*open_file)(struct ui_file_browser *, struct ui_file_attrs *attrs);
int (*delete_file)(struct ui_file_browser *, struct ui_file_attrs *attrs);
int (*move_file_preview)(struct ui_file_browser *_bro, struct rect *dst, struct rect *src);
void (*file_browser_close)(struct ui_file_browser *);
};
extern /* const */ struct ui_platform_api *platform_api;
extern /* const */ struct element_event_handler dumy_handler;
struct janimation {
u8 persent[5];
u8 direction;
u8 play_state;
u8 iteration_count;
u16 delay;
u16 duration;
struct element_css css[0];
};
extern struct element_event_handler *elm_event_handler_begin;
extern struct element_event_handler *elm_event_handler_end;
#define ___REGISTER_UI_EVENT_HANDLER(style, _id) \
static const struct element_event_handler element_event_handler_##_id \
sec(.elm_event_handler_##style) __attribute__((used)) = { \
.id = _id,
#define __REGISTER_UI_EVENT_HANDLER(style, _id) \
___REGISTER_UI_EVENT_HANDLER(style, _id)
#define REGISTER_UI_EVENT_HANDLER(id) \
__REGISTER_UI_EVENT_HANDLER(STYLE_NAME, id)
struct ui_style_info {
const char *name;
struct element_event_handler *begin;
struct element_event_handler *end;
};
extern struct ui_style_info ui_style_begin[];
extern struct ui_style_info ui_style_end[];
#define __REGISTER_UI_STYLE(style_name) \
extern struct element_event_handler elm_event_handler_begin_##style_name[]; \
extern struct element_event_handler elm_event_handler_end_##style_name[]; \
static const struct ui_style_info ui_style_##style_name sec(.ui_style) __attribute__((used)) = { \
.name = #style_name, \
.begin = elm_event_handler_begin_##style_name, \
.end = elm_event_handler_end_##style_name, \
};
#define REGISTER_UI_STYLE(style_name) \
__REGISTER_UI_STYLE(style_name)
static inline struct element_event_handler *element_event_handler_for_id(u32 id)
{
struct element_event_handler *p;
for (p = elm_event_handler_begin; p < elm_event_handler_end; p++) {
if (p->id == id) {
return p;
}
}
return NULL;
}
#define ui_core_get_element_css(elm) \
&((struct element *)(elm))->css
#define ui_core_element_invisable(elm, i) \
((struct element *)(elm))->css.invisible = i
int ui_core_init(const struct ui_platform_api *api, struct rect *rect);
int ui_core_set_style(const char *style);
void ui_core_set_rotate(int _rotate);
int ui_core_get_rotate();
void *ui_core_malloc(int size);
void ui_core_free(void *buf);
void ui_core_element_init(struct element *,
u32 id,
u8 page,
u8 prj,
/* const */ struct element_css1 *,
const struct element_event_handler *,
const struct element_event_action *);
void ui_core_get_element_abs_rect(struct element *elm, struct rect *rect);
void ui_core_append_child(void *_child);
struct element *ui_core_get_first_child();
void ui_core_remove_element(void *_child);
int ui_core_open_draw_context(struct draw_context *dc, struct element *elm);
int ui_core_close_draw_context(struct draw_context *dc);
int ui_core_show(void *_elm, int init);
int ui_core_hide(void *_elm);
struct element *get_element_by_id(struct element *elm, u32 id);
struct element *ui_core_get_element_by_id(u32 id);
int ui_core_get_disp_status_by_id(u32 id);
struct element *ui_core_get_up_element(struct element *elm);
struct element *ui_core_get_down_element(struct element *elm);
struct element *ui_core_get_left_element(struct element *elm);
struct element *ui_core_get_right_element(struct element *elm);
int ui_core_element_ontouch(struct element *, struct element_touch_event *e);
int ui_core_ontouch(struct element_touch_event *e);
int ui_core_element_onkey(struct element *elm, struct element_key_event *e);
int ui_core_onkey(struct element_key_event *e);
void ui_core_element_append_child(struct element *parent, struct element *child);
struct element_css *ui_core_set_element_css(void *_elm, const struct element_css1 *css);
int ui_core_invert_rect(struct draw_context *dc);
void ui_core_release_child_probe(struct element *elm);
void ui_core_release_child(struct element *elm);
int ui_core_redraw(void *_elm);
int ui_core_highlight_element(struct element *elm, int yes);
void ui_core_element_on_focus(struct element *elm, int yes);
void ui_core_ontouch_lose_focus(struct element *elm);
void ui_core_ontouch_lock(struct element *elm);
void ui_core_ontouch_unlock(struct element *elm);
int ui_core_get_draw_context(struct draw_context *dc, struct element *elm, struct rect *draw);
#endif

View File

@ -0,0 +1,149 @@
#ifndef UI_GRID_H
#define UI_GRID_H
#include "ui/ui_core.h"
#include "ui/control.h"
enum {
GRID_SCROLL_MODE,
GRID_PAGE_MODE,
};
enum {
SCROLL_DIRECTION_NONE,
SCROLL_DIRECTION_LR,
SCROLL_DIRECTION_UD,
};
struct ui_grid_item_info {
u8 row;
u8 col;
u8 page_mode;
u8 highlight_index;
u16 interval;
struct layout_info *info;
};
struct scroll_area {
int left;
int top;
int right;
int bottom;
};
struct ui_grid_dynamic {
int dhi_index;
int dcol_num;
int drow_num;
int min_row_index;
int max_row_index;
int min_col_index;
int max_col_index;
int min_show_row_index;
int max_show_row_index;
int min_show_col_index;
int max_show_col_index;
int grid_xval;
int grid_yval;
u8 grid_col_num;
u8 grid_row_num;
u8 grid_show_row;
u8 grid_show_col;
int base_index_once;
};
struct ui_grid {
struct element elm;
// char hi_num;
char hi_index;
char touch_index;
char onfocus;
u8 page_mode;
u8 slide_direction;
u8 col_num;
u8 row_num;
u8 show_row;
u8 show_col;
u8 avail_item_num;
u8 pix_scroll;
u8 ctrl_num;
// u8 rotate;
int x_interval;
int y_interval;
int max_show_left;
int max_show_top;
int min_show_left;
int min_show_top;
int max_left;
int max_top;
int min_left;
int min_top;
// int scroll_step;
// u8 ctrl_num;
struct scroll_area *area;
struct layout *item;
struct layout_info *item_info;
// struct element elm2;
struct ui_grid_dynamic *dynamic;
struct position pos;
struct draw_context dc;
const struct ui_grid_info *info;
const struct element_event_handler *handler;
};
extern const struct element_event_handler grid_elm_handler;
static inline int ui_grid_cur_item(struct ui_grid *grid)
{
if (grid->touch_index >= 0) {
return grid->touch_index;
}
return grid->hi_index;
}
#define ui_grid_set_item(grid, index) (grid)->hi_index = index
void ui_grid_enable();
void ui_grid_on_focus(struct ui_grid *grid);
void ui_grid_lose_focus(struct ui_grid *grid);
void ui_grid_state_reset(struct ui_grid *grid, int highlight_item);
int ui_grid_highlight_item(struct ui_grid *grid, int item, bool yes);
int ui_grid_highlight_item_by_id(int id, int item, bool yes);
struct ui_grid *__ui_grid_new(struct element_css1 *css, int id, struct ui_grid_item_info *info, struct element *parent);
int ui_grid_slide(struct ui_grid *grid, int direction, int steps);
int ui_grid_set_item_num(struct ui_grid *grid, int item_num);
int ui_grid_set_slide_direction(struct ui_grid *grid, int dir);
int ui_grid_slide_with_callback(struct ui_grid *grid, int direction, int steps, void(*callback)(void *ctrl));
int ui_grid_dynamic_slide(struct ui_grid *grid, int direction, int steps);//动态列表滚动
int ui_grid_dynamic_create(struct ui_grid *grid, int direction, int list_total, int (*event_handler_cb)(void *, int, int, int)); //动态列表创建
int ui_grid_dynamic_release(struct ui_grid *grid);//动态列表释放
int ui_grid_dynamic_cur_item(struct ui_grid *grid);//动态列表获取选项
int ui_grid_dynamic_set_item_by_id(int id, int count);//修改动态列表数
int ui_grid_dynamic_reset(struct ui_grid *grid, int index); //重置动态列表
void ui_grid_set_scroll_area(struct ui_grid *grid, struct scroll_area *area);
int ui_grid_init_dynamic(struct ui_grid *grid, int *row, int *col);
int ui_grid_add_dynamic(struct ui_grid *grid, int *row, int *col, int redraw);
int ui_grid_del_dynamic(struct ui_grid *grid, int *row, int *col, int redraw);
int ui_grid_set_hi_index(struct ui_grid *grid, int hi_index);
int ui_grid_set_pix_scroll(struct ui_grid *grid, int enable);
int ui_grid_get_hindex(struct ui_grid *grid);
int ui_grid_set_hindex_dynamic(struct ui_grid *grid, int dhindex, int init, int hi_index);
int ui_grid_get_hindex_dynamic(struct ui_grid *grid);
int ui_grid_set_base_dynamic(struct ui_grid *grid, u32 base_index_once);
// int ui_grid_update_by_id_dynamic(int id, int redraw);
int ui_grid_update_by_id_dynamic(int id, int item_sel, int redraw);
int ui_grid_add_dynamic_by_id(int id, int *row, int *col, int redraw);
int ui_grid_del_dynamic_by_id(int id, int *row, int *col, int redraw);
int ui_grid_cur_item_dynamic(struct ui_grid *grid);
#endif

View File

@ -0,0 +1,44 @@
#ifndef UI_NUMBER_H
#define UI_NUMBER_H
#include "ui/control.h"
#include "ui/ui_core.h"
#include "ui/p.h"
enum {
TYPE_NUM,
TYPE_STRING,
};
struct unumber {
u8 numbs;
u8 type;
u32 number[2];
u8 *num_str;
};
struct ui_number {
struct element_text text;
char source[8];
u16 number[2];
u16 buf[20];
int color;
int hi_color;
u8 css_num;
u8 nums: 6;
u8 type: 2;
u32 css[2];
u8 *num_str;
const struct ui_number_info *info;
const struct element_event_handler *handler;
};
void ui_number_enable();
void *new_ui_number(const void *_info, struct element *parent);
int ui_number_update(struct ui_number *number, struct unumber *n);
int ui_number_update_by_id(int id, struct unumber *n);
#endif

View File

@ -0,0 +1,30 @@
#ifndef UI_PIC_H
#define UI_PIC_H
#include "ui/ui_core.h"
struct ui_pic {
struct element elm;
u8 index;
// u8 css_num:2;
// u32 css[2];
// u16 highlight_img;
// u16 normal_img;
// u16 highlight_img_num:8;
// u16 normal_img_num:8;
const struct ui_pic_info *info;
const struct element_event_handler *handler;
};
void ui_pic_enable();
void *new_ui_pic(const void *_info, struct element *parent);
int ui_pic_show_image_by_id(int id, int index);
int ui_pic_set_image_index(struct ui_pic *pic, int index);
int ui_pic_get_normal_image_number_by_id(int id);
int ui_pic_get_highlgiht_image_number_by_id(int id);
int ui_pic_set_hide_by_id(int id, int hide);
#endif

Some files were not shown because too many files have changed in this diff Show More