193 lines
3.6 KiB
C
193 lines
3.6 KiB
C
/****************************************************************************
|
|
|
|
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
|
|
|
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
|
be copied by any method or incorporated into another program without
|
|
the express written consent of Aerospace C.Power. This Information or any portion
|
|
thereof remains the property of Aerospace C.Power. The Information contained herein
|
|
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
|
liability for its use in any way and conveys no license or title under
|
|
any patent or copyright and makes no representation or warranty that this
|
|
Information is free from patent or copyright infringement.
|
|
|
|
****************************************************************************/
|
|
/* os shim includes */
|
|
#include "os_types.h"
|
|
#include "os_task.h"
|
|
#include "os_utils.h"
|
|
|
|
/* common includes */
|
|
#include "iot_io.h"
|
|
#include "iot_bitops.h"
|
|
#include "iot_config.h"
|
|
|
|
/* driver includes */
|
|
#include "iot_clock.h"
|
|
#include "iot_uart.h"
|
|
|
|
/* cli includes */
|
|
#include "iot_uart_h.h"
|
|
|
|
/* debug includes*/
|
|
#include "dbg_io.h"
|
|
|
|
extern int platform_init();
|
|
|
|
os_task_h test_init_handle;
|
|
|
|
void addr_invalid()
|
|
{
|
|
volatile uint32_t *reg = (volatile uint32_t *) 0x620000c0;
|
|
|
|
*reg &= ~0x2;
|
|
|
|
iot_printf("reg: %08x\n", *reg);
|
|
|
|
|
|
int *buf = (int *)0xffe0000;
|
|
//*buf = 0xaabbccdd;
|
|
iot_printf("align test a: %08x\r\n", *(buf));
|
|
}
|
|
|
|
void misalign_access()
|
|
{
|
|
uint32_t addr = 0x1003ffd1;
|
|
iot_printf("addr: %08x\n", addr);
|
|
volatile uint32_t *a = (volatile uint32_t *) addr;
|
|
//*a = 0xaabb;
|
|
//*(a+1) = 0xccdd;
|
|
iot_printf("align test a: %08x\r\n", *(a));
|
|
iot_printf("align test a: %08x\r\n", *(a+1));
|
|
}
|
|
|
|
void instruction_illegal()
|
|
{
|
|
void (*pgm_start)(void) = (void*) 0x001003d1;
|
|
pgm_start();
|
|
}
|
|
|
|
void invalid_instruction_access()
|
|
{
|
|
void (*pgm_start)(void) = (void*) 0x80000040;
|
|
pgm_start();
|
|
}
|
|
|
|
void exception_test(void)
|
|
{
|
|
#if 1
|
|
iot_printf("invalid_instruction_access\n");
|
|
invalid_instruction_access();
|
|
#endif
|
|
|
|
#if 1
|
|
iot_printf("instruction_illegal\n");
|
|
instruction_illegal();
|
|
#endif
|
|
|
|
#if 1
|
|
iot_printf("misalign_access\n");
|
|
misalign_access();
|
|
#endif
|
|
|
|
#if 1
|
|
iot_printf("addr_invalid\n");
|
|
addr_invalid();
|
|
#endif
|
|
}
|
|
|
|
void test_init()
|
|
{
|
|
/* init common modules */
|
|
iot_bitops_init();
|
|
|
|
/* init os related modules and utilities */
|
|
os_utils_init();
|
|
|
|
/*init uart module*/
|
|
iot_uart_init(1);
|
|
|
|
exception_test();
|
|
}
|
|
|
|
|
|
void iot_task_1(void *arg)
|
|
{
|
|
iot_printf("task 1 entry....\n");
|
|
|
|
for(;;) {
|
|
test_init();
|
|
os_delete_task(test_init_handle);
|
|
}
|
|
|
|
}
|
|
|
|
int32_t iot_task_init()
|
|
{
|
|
/* start plc lib task */
|
|
test_init_handle = os_create_task(iot_task_1, NULL, 9);
|
|
|
|
//create the tasks;
|
|
if(test_init_handle != NULL) {
|
|
iot_printf("task 1 init successfully...\n");
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int32_t iot_task_start()
|
|
{
|
|
//start the tasks;
|
|
os_start_kernel();
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int32_t iot_platform_init()
|
|
{
|
|
/*platform intialization*/
|
|
platform_init();
|
|
|
|
//resource initializations;
|
|
system_clock_init();
|
|
|
|
system_uart_init();
|
|
|
|
dbg_uart_init();
|
|
|
|
dbg_uart_stage1_init();
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
int32_t iot_module_init(void)
|
|
{
|
|
//platform intialization;
|
|
iot_platform_init();
|
|
|
|
//create all the tasks;
|
|
iot_task_init();
|
|
|
|
iot_printf("starting...\n");
|
|
|
|
return 0;
|
|
}
|
|
|
|
int32_t iot_module_start(void)
|
|
{
|
|
int32_t res = 0;
|
|
|
|
res = iot_task_start();
|
|
|
|
return res;
|
|
}
|
|
#include "apb_dma.h"
|
|
int main(void)
|
|
{
|
|
//module init;
|
|
iot_module_init();
|
|
iot_module_start();
|
|
return 0;
|
|
}
|