748 lines
18 KiB
C
Executable File
748 lines
18 KiB
C
Executable File
|
|
#include "os_types.h"
|
|
#include "os_task.h"
|
|
#include "os_mem.h"
|
|
|
|
#include "dbg_io.h"
|
|
#include "iot_diag.h"
|
|
#include "iot_io.h"
|
|
|
|
|
|
|
|
//#include <stdlib.h>
|
|
#include "iot_system_api.h"
|
|
#include "iot_config.h"
|
|
|
|
|
|
|
|
|
|
//#include "iot_gptmr.h"
|
|
#include "iot_system.h"
|
|
//#include "os_mem.h"
|
|
//#include "cpu.h"
|
|
//#include "os_task.h"
|
|
|
|
#include "platform.h"
|
|
#include "encoding.h"
|
|
|
|
//#include "sec_glb.h"
|
|
//#include "ahb.h"
|
|
//#include "intc.h"
|
|
|
|
#include "bits.h"
|
|
|
|
#include "os_utils.h"
|
|
|
|
#include "iot_rtc.h"
|
|
|
|
|
|
#include "chip_reg_base.h"
|
|
#include "hw_reg_api.h"
|
|
#include "iot_bitops.h"
|
|
#include "flash.h"
|
|
#include "os_lock.h"
|
|
#include "iot_config.h"
|
|
#include "ahb.h"
|
|
#include "sec_glb.h"
|
|
|
|
#if HW_PLATFORM > HW_PLATFORM_SIMU
|
|
#include "dbg_io.h"
|
|
#endif
|
|
#include "iot_io.h"
|
|
|
|
#define SFC_API_TEST 1
|
|
|
|
#if SFC_API_TEST == 1
|
|
#include "sfc.h"
|
|
#endif
|
|
|
|
#define FLASH_TEST_OFFSET (0x100000)
|
|
uint8_t rdata[0x1000] = {0};
|
|
uint8_t wdata[0x1000] = {1,2,3,4,5,6,7,8,9,0,255,254,253,252,251,250};
|
|
|
|
|
|
#include "chip_reg_base.h"
|
|
#include "hw_reg_api.h"
|
|
#include "iot_bitops.h"
|
|
#include "os_lock.h"
|
|
#include "iot_config.h"
|
|
#include "sram.h"
|
|
#include "os_mem.h"
|
|
#include "smc.h"
|
|
#if HW_PLATFORM > HW_PLATFORM_SIMU
|
|
#include "dbg_io.h"
|
|
#endif
|
|
#include "iot_io.h"
|
|
|
|
#include "ahb.h"
|
|
#include "sec_glb.h"
|
|
|
|
#define CLK 48 //16 //48
|
|
#define PSRAM_ACCSEE_WAY 0 //0:cache 1:software
|
|
|
|
|
|
extern void sfc_bus_share_en();
|
|
|
|
|
|
|
|
static int32_t iot__platform_init()
|
|
{
|
|
/*platform intialization*/
|
|
platform_init();
|
|
dbg_uart_init();
|
|
|
|
return 0;
|
|
}
|
|
|
|
void get_id_test()
|
|
{
|
|
uint8_t param[0x100] = {0};
|
|
iot_printf("[SFDP data]\n");
|
|
sfc_read_sfdp(param, 0x0, 0x4);
|
|
iot_printf("0x0: %x %x %x %x\n", param[0], param[1], param[2], param[3]);
|
|
sfc_read_sfdp(param, 0x10, 0x4);
|
|
iot_printf("0x0: %x %x %x %x\n", param[0], param[1], param[2], param[3]);
|
|
|
|
iot_printf("\n[SFC API TEST] start get id test\n");
|
|
//g_sfc_ctrl->get_dev_id(rdata);
|
|
iot_printf("Manufacturer ID:%x%x\r\n",rdata[1], rdata[0]);
|
|
sfc_qspi_get_id_mult(rdata, MOD_SFC_SERIAL);
|
|
iot_printf("Manufacturer ID:%x%x\r\n",rdata[1], rdata[0]);
|
|
sfc_qspi_get_id_mult(rdata, MOD_SFC_DUAL);
|
|
iot_printf("Manufacturer ID dual: %x%x\r\n",rdata[1], rdata[0]);
|
|
sfc_qspi_get_id_mult(rdata, MOD_SFC_QUAD);
|
|
iot_printf("Manufacturer ID quad: %x%x\r\n",rdata[1], rdata[0]);
|
|
iot_printf("[SFC API TEST] end get id test\n");
|
|
}
|
|
|
|
void get_sts_reg_test()
|
|
{
|
|
uint8_t data;
|
|
uint8_t reg = 0;
|
|
iot_printf("\n[SFC API TEST] start get status reg test\n");
|
|
g_sfc_ctrl->get_sts_reg(&data, reg);
|
|
iot_printf("get reg[%d]: %08x\n ", reg, data);
|
|
reg = 1;
|
|
g_sfc_ctrl->get_sts_reg(&data, reg);
|
|
iot_printf("get reg[%d]: %08x\n ", reg, data);
|
|
iot_printf("[SFC API TEST] end get status reg test\n");
|
|
}
|
|
|
|
void erase_test(void)
|
|
{
|
|
uint32_t i = 0, error = 0;
|
|
|
|
iot_printf("erase sector test\n");
|
|
|
|
os_mem_set(rdata,0,sizeof(rdata));
|
|
g_sfc_ctrl->erase_sector(FLASH_TEST_OFFSET, MOD_SW_MODE_DIS); //4k
|
|
|
|
for (i=0; i<0x10; i++) {
|
|
g_sfc_ctrl->read(rdata+0x100*i,(FLASH_TEST_OFFSET+0x100*i),0x100, MOD_SFC_READ_SIG); //read page 256
|
|
}
|
|
|
|
for (i=0;i<sizeof(rdata);i++) {
|
|
if (rdata[i] != 0xff) {
|
|
error++;
|
|
}
|
|
}
|
|
|
|
if (error != 0) {
|
|
iot_printf("ERROR erase sector failed\n");
|
|
} else {
|
|
iot_printf("erase sector success\n");
|
|
}
|
|
}
|
|
|
|
|
|
void write_test()
|
|
{
|
|
uint32_t i = 0,error = 0;
|
|
iot_printf("\n[SFC API TEST] start write test\n");
|
|
|
|
for (i=0; i<sizeof(wdata); i++){
|
|
wdata[i] = i;
|
|
}
|
|
|
|
//////////////////////////////////////////
|
|
iot_printf("qspi write test\n");
|
|
error = 0;
|
|
os_mem_set(rdata,0,sizeof(rdata));
|
|
//g_sfc_ctrl->erase_sector(FLASH_TEST_OFFSET, MOD_SW_MODE_DIS); //4k
|
|
erase_test();
|
|
for (i=0; i<0x10; i++) {
|
|
g_sfc_ctrl->write((wdata+0x100*i),(FLASH_TEST_OFFSET+0x100*i), 0x100,
|
|
MOD_SFC_PROG_STAND, MOD_SW_MODE_DIS); //write page 256
|
|
}
|
|
|
|
for (i=0; i<0x10; i++) {
|
|
g_sfc_ctrl->read(rdata+0x100*i,(FLASH_TEST_OFFSET+0x100*i),0x100, MOD_SFC_READ_SIG); //read page 256
|
|
}
|
|
|
|
for (i=0; i<sizeof(rdata); i++){
|
|
if (rdata[i] != i%256) {
|
|
error++;
|
|
}
|
|
}
|
|
|
|
if (error != 0) {
|
|
iot_printf("ERROR qspi write, qspi read error\n");
|
|
} else {
|
|
iot_printf("qspi write, qspi read success\n");
|
|
}
|
|
os_delay(5);
|
|
|
|
//////////////////////////////////////////
|
|
iot_printf("\n\rquad write test\n");
|
|
error = 0;
|
|
os_mem_set(rdata,0,sizeof(rdata));
|
|
// g_sfc_ctrl->erase_sector(FLASH_TEST_OFFSET, MOD_SW_MODE_DIS); //4k
|
|
erase_test();
|
|
for (i=0; i<0x10; i++) {
|
|
g_sfc_ctrl->write((wdata+0x100*i),(FLASH_TEST_OFFSET+0x100*i),0x100,
|
|
MOD_SFC_PROG_QUAD, MOD_SW_MODE_DIS);
|
|
}
|
|
|
|
for (i=0; i<0x10; i++) {
|
|
g_sfc_ctrl->read(rdata+0x100*i,(FLASH_TEST_OFFSET+0x100*i),0x100, MOD_SFC_READ_SIG); //read page 256
|
|
}
|
|
|
|
for (i=0; i<sizeof(rdata); i++){
|
|
if (rdata[i] != i%256) {
|
|
error++;
|
|
}
|
|
}
|
|
|
|
if (error != 0) {
|
|
iot_printf("ERROR quad write, quad read error\n");
|
|
} else {
|
|
iot_printf("quad write, quad read success\n");
|
|
}
|
|
|
|
os_delay(5);
|
|
iot_printf("[SFC API TEST] end write test\n");
|
|
}
|
|
|
|
void read_test()
|
|
{
|
|
uint32_t i = 0,error = 0;
|
|
|
|
iot_printf("\n[SFC API TEST] start read test\n");
|
|
iot_printf("read test\n");
|
|
|
|
os_mem_set(rdata,0,sizeof(rdata));
|
|
for (i=0; i<0x10; i++) {
|
|
g_sfc_ctrl->read(rdata+0x100*i,(FLASH_TEST_OFFSET+0x100*i),0x100, MOD_SFC_READ_SIG); //read page 256
|
|
}
|
|
|
|
for (i=0; i<sizeof(rdata); i++){
|
|
if (rdata[i] != i%256) {
|
|
error++;
|
|
}
|
|
}
|
|
|
|
if (error != 0) {
|
|
iot_printf("ERROR sig read error\n");
|
|
} else {
|
|
iot_printf("sig read success\n");
|
|
}
|
|
os_delay(5);
|
|
|
|
///////////////
|
|
error = 0;
|
|
os_mem_set(rdata,0,sizeof(rdata));
|
|
for (i=0; i<0x10; i++) {
|
|
g_sfc_ctrl->read(rdata+0x100*i,(FLASH_TEST_OFFSET+0x100*i),0x100, MOD_SFC_READ_HIGH_SPD); //read page 256
|
|
}
|
|
|
|
for (i=0; i<sizeof(rdata); i++){
|
|
if (rdata[i] != i%256) {
|
|
error++;
|
|
}
|
|
}
|
|
|
|
if (error != 0) {
|
|
iot_printf("ERROR high speed read error\n");
|
|
} else {
|
|
iot_printf("high speed read success\n");
|
|
}
|
|
os_delay(5);
|
|
|
|
//////////////
|
|
error = 0;
|
|
os_mem_set(rdata,0,sizeof(rdata));
|
|
for (i=0; i<0x10; i++) {
|
|
g_sfc_ctrl->read(rdata+0x100*i,(FLASH_TEST_OFFSET+0x100*i),0x100, MOD_SFC_READ_DUAL_FAST); //read page 256
|
|
}
|
|
|
|
for (i=0; i<sizeof(rdata); i++){
|
|
if (rdata[i] != i%256) {
|
|
error++;
|
|
}
|
|
}
|
|
|
|
if (error != 0) {
|
|
iot_printf("ERROR dual fast read error\n");
|
|
} else {
|
|
iot_printf("dual fast read success\n");
|
|
}
|
|
os_delay(5);
|
|
|
|
///////////////
|
|
error = 0;
|
|
os_mem_set(rdata,0,sizeof(rdata));
|
|
for (i=0; i<0x10; i++) {
|
|
g_sfc_ctrl->read(rdata+0x100*i,(FLASH_TEST_OFFSET+0x100*i),0x100, MOD_SFC_READ_QUAD_FAST); //read page 256
|
|
}
|
|
|
|
for (i=0; i<sizeof(rdata); i++){
|
|
if (rdata[i] != i%256) {
|
|
error++;
|
|
}
|
|
}
|
|
|
|
if (error != 0) {
|
|
iot_printf("ERROR quad fast read error\n");
|
|
} else {
|
|
iot_printf("quad fast read success\n");
|
|
}
|
|
os_delay(5);
|
|
|
|
///////////////
|
|
error = 0;
|
|
os_mem_set(rdata,0,sizeof(rdata));
|
|
for (i=0; i<0x10; i++) {
|
|
g_sfc_ctrl->read(rdata+0x100*i,(FLASH_TEST_OFFSET+0x100*i),0x100, MOD_SFC_READ_DUAL_IO_FAST); //read page 256
|
|
}
|
|
|
|
for (i=0; i<sizeof(rdata); i++){
|
|
if (rdata[i] != i%256) {
|
|
error++;
|
|
}
|
|
}
|
|
|
|
if (error != 0) {
|
|
iot_printf("ERROR dual io fast read error\n");
|
|
} else {
|
|
iot_printf("dual io fast read success\n");
|
|
}
|
|
os_delay(5);
|
|
|
|
///////////////
|
|
error = 0;
|
|
os_mem_set(rdata,0,sizeof(rdata));
|
|
for (i=0; i<0x10; i++) {
|
|
g_sfc_ctrl->read(rdata+0x100*i,(FLASH_TEST_OFFSET+0x100*i),0x100, MOD_SFC_READ_QUAD_IO_FAST); //read page 256
|
|
}
|
|
|
|
for (i=0; i<sizeof(rdata); i++){
|
|
if (rdata[i] != i%256) {
|
|
error++;
|
|
}
|
|
}
|
|
|
|
if (error != 0) {
|
|
iot_printf("ERROR quad io fast read error\n");
|
|
} else {
|
|
iot_printf("quad io fast read success\n");
|
|
}
|
|
os_delay(5);
|
|
|
|
///////////////
|
|
error = 0;
|
|
os_mem_set(rdata,0,sizeof(rdata));
|
|
for (i=0; i<0x10; i++) {
|
|
g_sfc_ctrl->read(rdata+0x100*i,(FLASH_TEST_OFFSET+0x100*i),0x100, MOD_SFC_READ_QUAD_IO_WORD_FAST); //read page 256
|
|
}
|
|
|
|
for (i=0; i<sizeof(rdata); i++){
|
|
if (rdata[i] != i%256) {
|
|
error++;
|
|
}
|
|
}
|
|
|
|
if (error != 0) {
|
|
iot_printf("ERROR quad io word fast read error\n");
|
|
} else {
|
|
iot_printf("quad io word fast read success\n");
|
|
}
|
|
os_delay(5);
|
|
|
|
iot_printf("[SFC API TEST] end read test\n");
|
|
}
|
|
|
|
void sfc_cache_read_test()
|
|
{
|
|
uint32_t i = 0,rdata = 0, error = 0;
|
|
|
|
iot_printf("\n[SFC API TEST] start cache read test\n");
|
|
|
|
iot_printf(" read flash by cache0\n");
|
|
for (i=0;i<sizeof(wdata);i++) {
|
|
rdata = *(volatile uint8_t *)(0x14000000+FLASH_TEST_OFFSET+i);
|
|
if (rdata != i%256) {
|
|
iot_printf("ERROR cache flash read: rdata[%d] = %02x\n",i, rdata);
|
|
error++;
|
|
}
|
|
}
|
|
os_delay(5);
|
|
|
|
iot_printf("read flash by cache1\n");
|
|
for (i=0;i<sizeof(wdata);i++) {
|
|
rdata = *(volatile uint8_t *)(0x1c000000+FLASH_TEST_OFFSET+i);
|
|
if (rdata != i%256) {
|
|
iot_printf("ERROR cache flash read: rdata[%d] = %02x\n",i, rdata);
|
|
error++;
|
|
}
|
|
}
|
|
os_delay(5);
|
|
|
|
iot_printf("read flash by cache2\n");
|
|
for (i=0;i<sizeof(wdata);i++) {
|
|
rdata = *(volatile uint8_t *)(0x24000000+FLASH_TEST_OFFSET+i);
|
|
if (rdata != i%256) {
|
|
iot_printf("ERROR cache flash read: rdata[%d] = %02x\n",i, rdata);
|
|
error++;
|
|
}
|
|
}
|
|
os_delay(5);
|
|
|
|
iot_printf("read flash by cache3\n");
|
|
for (i=0;i<sizeof(wdata);i++) {
|
|
rdata = *(volatile uint8_t *)(0x2c000000+FLASH_TEST_OFFSET+i);
|
|
if (rdata != i%256) {
|
|
iot_printf("ERROR cache flash read: rdata[%d] = %02x\n",i, rdata);
|
|
error++;
|
|
}
|
|
}
|
|
|
|
if (0 == error) {
|
|
iot_printf("flash cache0~4 read test success\r\n");
|
|
}else {
|
|
iot_printf("flash cache0~4 read test failed\r\n");
|
|
}
|
|
|
|
}
|
|
|
|
void sfc_main() {
|
|
uint8_t wip_sts;
|
|
uint32_t loop = 0;
|
|
|
|
iot_printf("\r\n>>>>>>>>>>>>>>>>>>>>>>>>flash read && write test begin<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\r\n");
|
|
|
|
/* init sfc and flash */
|
|
flash_init(1);
|
|
|
|
do {
|
|
iot_printf("quad: %d\n", g_sfc_ctrl->is_quad);
|
|
|
|
get_id_test();
|
|
|
|
get_sts_reg_test();
|
|
|
|
g_sfc_ctrl->query_wip_sts(&wip_sts);
|
|
|
|
if(wip_sts == 1) {
|
|
iot_printf("FLASH is WORK IN STATUS\r\n");
|
|
} else{
|
|
|
|
erase_test();
|
|
write_test();
|
|
read_test();
|
|
sfc_cache_read_test();
|
|
erase_test();
|
|
os_delay(5);
|
|
}
|
|
loop++;
|
|
iot_printf("\r\n>>>>>>>>>>>>>>>>>>>>>>>>>>>flash read && write test cnt : %d<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\r\n",loop);
|
|
} while (1);
|
|
|
|
while(1)
|
|
{
|
|
|
|
iot_printf("user_task_test_1 \n");
|
|
os_delay(1000);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
void smc_main() {
|
|
uint32_t loop = 0;
|
|
uint8_t rdata[0x40] = {0};
|
|
uint8_t wdata[0x40] = {1,2,3,4,5,6,7,8,9,0x11,0x22,0x33,0x44};
|
|
|
|
int i = 0, j = 0, k = 0;
|
|
int offset = 0;
|
|
int len = sizeof(wdata);
|
|
|
|
for(i = 0; i < len; i++) {
|
|
wdata[i] = 0x5a;
|
|
}
|
|
|
|
iot_printf("\r\n-------------------------------psram read && write test begin-------------------------------\r\n");
|
|
|
|
if(PSRAM_ACCSEE_WAY == 0)
|
|
{
|
|
while(1) {
|
|
int i,j,error = 0;
|
|
uint32_t rdat;
|
|
for (j=0;j<100;j++)
|
|
{
|
|
for (i=0;i<1000;i++)
|
|
{
|
|
*((volatile uint32_t*)(0x18300000+i*4+1000*4*j)) = 0x12345678+i+j;
|
|
}
|
|
ahb_cachex_flush(1,0x18300000+1000*4*j, 0x400*4);
|
|
ahb_cachex_flush(0,0x10100000,1024*1024);
|
|
|
|
for (i=0;i<1000;i++)
|
|
{
|
|
rdat=((volatile uint32_t)*((volatile uint32_t*)(0x10300000+i*4+1000*4*j)));
|
|
if(((0x12345678+i+j) != rdat))
|
|
{
|
|
iot_printf("ERROR addr 0x%x, WR:0x%x, RD 0x%X\r\n",(0x10300000+i*4+1000*4*j), (0x12345678+i+j),rdat);
|
|
error++;
|
|
}
|
|
}
|
|
os_delay(1);
|
|
}
|
|
|
|
for (j=0;j<100;j++)
|
|
{
|
|
for (i=0;i<1000;i++)
|
|
{
|
|
*((volatile uint32_t*)(0x28300000+i*4+1000*4*j)) = 0x12345678+i+j;
|
|
}
|
|
ahb_cachex_flush(3,0x28300000+1000*4*j, 0x400*4);
|
|
ahb_cachex_clear(2);
|
|
|
|
for (i=0;i<1000;i++)
|
|
{
|
|
rdat=((volatile uint32_t)*((volatile uint32_t*)(0x20300000+i*4+1000*4*j)));
|
|
if(((0x12345678+i+j) != rdat))
|
|
{
|
|
iot_printf("ERROR addr 0x%x, WR:0x%x, RD 0x%X\r\n",(0x20300000+i*4+1000*4*j), (0x12345678+i+j),rdat);
|
|
error++;
|
|
}
|
|
}
|
|
os_delay(1);
|
|
}
|
|
|
|
if (0 == error) {
|
|
iot_printf("*********************psram cache0~4 flush and read test success***********************\r\n");
|
|
}else {
|
|
iot_printf("*********************psram cache0~4 flush and read test failed************************\r\n");
|
|
}
|
|
|
|
loop++;
|
|
iot_printf("\r\n------------------------------- psram read && write test cnt : %d -------------------------------\n\r",loop);
|
|
}
|
|
}else{
|
|
/* init sfc and sram */
|
|
sfc_bus_share_en();
|
|
sram_qspi_init();
|
|
|
|
hal_smc_spi_cfg(CLK);
|
|
do {
|
|
if(sram_qspi_is_busy() != HAL_SRAM_OK){
|
|
iot_printf("SRAM IS Busy Now!\r\n");
|
|
}else{
|
|
/* spi mode */
|
|
// sram_qspi_exit();
|
|
iot_printf("spi write & read \n");
|
|
wdata[10] = 0xaa;
|
|
sram_qspi_write(wdata,0x1000,sizeof(wdata));
|
|
|
|
while(sram_qspi_is_busy());
|
|
os_mem_set(rdata,0,sizeof(rdata));
|
|
sram_qspi_read(rdata,0x1000,sizeof(rdata));
|
|
iot_printf("wdata[10]:%x, rdata[10]:%x\n", wdata[10], rdata[10]);
|
|
if (wdata[10] != rdata[10]) {
|
|
iot_printf("ERROR!! qspi write, qspi read not match\n");
|
|
//return;
|
|
}
|
|
|
|
/* qpi mode */
|
|
iot_printf("qpi write & read \n");
|
|
|
|
sram_qspi_enter();
|
|
hal_smc_qspi_quad_cfg(CLK);
|
|
wdata[10] = 0xbb;
|
|
sram_qspi_quad_write(wdata,0x2000,sizeof(wdata));
|
|
while(sram_qspi_is_busy());
|
|
os_mem_set(rdata,0,sizeof(rdata));
|
|
|
|
sram_qspi_quad_read(rdata,0x2000,sizeof(rdata));
|
|
iot_printf("wdata[10]:%x, rdata[10]:%x\n", wdata[10], rdata[10]);
|
|
if (wdata[10] != rdata[10]) {
|
|
iot_printf(" quad write, quad read not match\n");
|
|
return;
|
|
}
|
|
/* write read test */
|
|
iot_printf(" write read loop test \n");
|
|
offset = 0;
|
|
j = 0;
|
|
for (j = 0; j < 10; j++) {
|
|
iot_printf("\r\n------loop %d offset %x------\r\n", j, offset);
|
|
sram_qspi_quad_write(wdata, 0x1000+offset,sizeof(wdata));
|
|
|
|
while(sram_qspi_is_busy());
|
|
os_mem_set(rdata,0,sizeof(rdata));
|
|
|
|
sram_qspi_quad_read(rdata, 0x1000 +offset, sizeof(rdata));
|
|
|
|
for(i=0; i<len; i++) {
|
|
if (i % 4 == 0 ) {
|
|
iot_printf("\r\naddr: %08x: ", offset+i);
|
|
}
|
|
iot_printf("%02x ", rdata[i]);
|
|
}
|
|
k = 0;
|
|
for(k=0;k<1000;k++);
|
|
offset += 0x40;
|
|
}
|
|
sram_qspi_exit();
|
|
return;
|
|
}
|
|
|
|
while(sram_qspi_is_busy());
|
|
} while (false);
|
|
}
|
|
|
|
while(1)
|
|
{
|
|
|
|
iot_printf("user_task_test_2 \n");
|
|
os_delay(1000);
|
|
}
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
void user_task_1()
|
|
{
|
|
sfc_main();
|
|
}
|
|
|
|
void user_task_2()
|
|
{
|
|
smc_main();
|
|
}
|
|
|
|
void user_task_test_1()
|
|
{
|
|
iot_time_tm_t curr_tm;
|
|
|
|
*((volatile uint32_t*)(0x05c0f808)) = 0xffffffff;
|
|
curr_tm.tm_year=2012;
|
|
curr_tm.tm_mon=1;
|
|
curr_tm.tm_mday=11;
|
|
curr_tm.tm_hour=4;
|
|
curr_tm.tm_min=55;
|
|
curr_tm.tm_sec=0;
|
|
|
|
iot_rtc_set(&curr_tm);
|
|
|
|
while(1)
|
|
{
|
|
iot_rtc_get(&curr_tm);
|
|
iot_printf("user_task_test_1 %d-%d-%d %d:%d:%d\n",curr_tm.tm_year,curr_tm.tm_mon,curr_tm.tm_mday,curr_tm.tm_hour,curr_tm.tm_min,curr_tm.tm_sec);
|
|
os_delay(500);
|
|
}
|
|
}
|
|
|
|
void user_task_test_2()
|
|
{
|
|
iot_time_tm_t curr_tm;
|
|
|
|
*((volatile uint32_t*)(0x05c0f808)) = 0xffffffff;
|
|
curr_tm.tm_year=2012;
|
|
curr_tm.tm_mon=1;
|
|
curr_tm.tm_mday=11;
|
|
curr_tm.tm_hour=4;
|
|
curr_tm.tm_min=55;
|
|
curr_tm.tm_sec=0;
|
|
|
|
iot_rtc_set(&curr_tm);
|
|
|
|
while(1)
|
|
{
|
|
iot_rtc_get(&curr_tm);
|
|
iot_printf("user_task_test_2 %d-%d-%d %d:%d:%d\n",curr_tm.tm_year,curr_tm.tm_mon,curr_tm.tm_mday,curr_tm.tm_hour,curr_tm.tm_min,curr_tm.tm_sec);
|
|
os_delay(500);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int32_t iot__task_init()
|
|
{
|
|
os_task_h handle;
|
|
|
|
//create the tasks;
|
|
#if 1
|
|
handle = os_create_task(user_task_1, NULL, 6);
|
|
//handle = os_create_task(user_task_test_1, NULL, 9);
|
|
|
|
if(handle != NULL) {
|
|
iot_printf("task 1 init successfully...\n");
|
|
}
|
|
#endif
|
|
#if 1
|
|
handle = NULL;
|
|
handle = os_create_task(user_task_2, NULL, 6);
|
|
//handle = os_create_task(user_task_test_2, NULL, 9);
|
|
if(handle != NULL) {
|
|
iot_printf("task 2 init successfully...\n");
|
|
}
|
|
#endif
|
|
return 0;
|
|
}
|
|
|
|
|
|
int32_t iot__module_init(void)
|
|
{
|
|
//platform intialization;
|
|
iot__platform_init();
|
|
|
|
//create all the tasks;
|
|
iot__task_init();
|
|
iot_rtc_init();
|
|
iot_printf("starting...\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
int32_t iot__task_start()
|
|
{
|
|
//start the tasks;
|
|
os_start_kernel();
|
|
|
|
return 0;
|
|
}
|
|
|
|
int32_t iot__module_start(void)
|
|
{
|
|
int32_t res = 0;
|
|
|
|
res = iot__task_start();
|
|
|
|
return res;
|
|
}
|
|
|
|
|
|
int main(void)
|
|
{
|
|
//module init;
|
|
iot__module_init();
|
|
|
|
//module start;
|
|
iot__module_start();
|
|
|
|
return 0;
|
|
}
|
|
|
|
|