Browse Source

update platform

Signed-off-by: surenyi <surenyi82@qq.com>
bfsk
surenyi 3 years ago
parent
commit
8fad8b8af4
  1. 3
      README.md
  2. 5
      include/platform.h
  3. 9
      platforms/S01/platform_s01.c
  4. 24
      platforms/dsk/plat_dsk.cmd
  5. 7
      platforms/dsk/platform_dsk.c
  6. 10
      src/platform.c
  7. 12
      src/tick.c

3
README.md

@ -14,4 +14,5 @@ cd build
cmake -G "Unix Makefiles" -DPLAT=S01 ..
```
其中 PLAT 参数支持 `dsk``S01`
其中 PLAT 参数支持 `dsk``S01`, 编译成功后,生成的库文件在 `lib/` 目录下,将 `include``lib` 目录复制到应用工程中,
开始应用程序的编写。

5
include/platform.h

@ -9,6 +9,7 @@ extern "C" {
#include "csl/csl_timer.h"
#include "csl/csl_emifb.h"
#include "csl/csl_emifa.h"
#include "csl/csl_mcbsp.h"
#include "tick.h"
int platform_init();
@ -23,7 +24,9 @@ Uint32 platform_read32(Uint32 addr);
void platform_write32(Uint32 addr, Uint32 val);
/* platform implementations */
int platform_emif_init();
void platform_pre_init();
void platform_post_init();
int platform_tick_timer_id();
unsigned long platform_cpu_freq();

9
platforms/S01/platform_s01.c

@ -1,7 +1,7 @@
#include "platform.h"
#include "platform_s01.h"
static int emifb_init(void)
void platform_pre_init(void)
{
EMIFB_Config emb;
@ -32,15 +32,10 @@ static int emifb_init(void)
/* EMIFB CE1: FLASH */
emb.cectl1 = EMIFB_CECTL_DEFAULT;
emb.cesec1 = EMIFB_CESEC_DEFAULT;
return 0;
}
int platform_emif_init()
void platform_post_init()
{
emifb_init();
return 0;
}
int platform_tick_timer_id()

24
platforms/dsk/plat_dsk.cmd

@ -0,0 +1,24 @@
MEMORY {
L2_BOOT : o = 00000000h l = 00000400h /* 1K */
L2 : o = 00000400h l = 000FFC00h /* all SRAM */
CE0 : o = 80000000h l = 00100000h /* external memory */
}
SECTIONS
{
.vecs > L2_BOOT
.cinit > L2
.text > L2
.stack > L2
.bss > L2
.const > L2
.data > L2
.far > L2
.switch > L2
.sysmem > L2
.tables > L2
.cio > L2
.external > CE0
}

7
platforms/dsk/platform_dsk.c

@ -35,11 +35,14 @@ static int emifb_init(void)
return 0;
}
int platform_emif_init()
void platform_pre_init()
{
emifb_init();
}
return 0;
void platform_post_init()
{
}
int platform_tick_timer_id()

10
src/platform.c

@ -7,15 +7,19 @@ int platform_init()
{
CSL_init();
IRQ_setVecs(vectors);
platform_pre_init();
platform_emif_init();
IRQ_setVecs(vectors);
IRQ_globalEnable();
IRQ_globalDisable();
IRQ_nmiEnable();
tick_init();
IRQ_globalEnable();
platform_post_init();
return 0;
}

12
src/tick.c

@ -1,6 +1,7 @@
#include "platform.h"
static TIMER_Handle tick_handle;
static Uint32 tick_event_id;
static void (*tick_callback)(void *arg);
static void *tick_callback_data;
@ -11,7 +12,6 @@ void * memset (void * ptr, int value, int num );
int tick_init()
{
TIMER_Config timconf;
Uint32 tick_event_id;
int devid = platform_tick_timer_id();
@ -57,6 +57,10 @@ int tick_init()
void tick_close()
{
if (tick_event_id > 0) {
IRQ_disable(tick_event_id);
tick_event_id = 0;
}
if (tick_handle) {
TIMER_pause(tick_handle);
TIMER_close(tick_handle);
@ -93,11 +97,15 @@ void delay(unsigned long ms)
{
Uint40 end = __current_time + ms;
if (end < __current_time) {
while (__current_time > 0)
;
}
while (__current_time < end)
;
}
#pragma CODE_SECTION(c_tick_handler, ".vecs")
#pragma CODE_SECTION(c_tick_handler, ".text:irqhandler")
interrupt void c_tick_handler(void)
{
++__current_time;

Loading…
Cancel
Save