Browse Source

add scatter file: xc_ppf1901.sct

Signed-off-by: surenyi <surenyi82@qq.com>
master
surenyi 6 years ago
parent
commit
0416d285a2
  1. 2
      .gitignore
  2. 4
      cmsis/src/startup_stm32f429_439xx.s
  3. 212
      target/cmd.c
  4. 31
      target/cmd.h
  5. 4
      target/lowlevel.c
  6. 3
      target/main.c
  7. 4
      target/retarget.c
  8. 1
      target/target.h
  9. 34
      xc_ppf1901.sct
  10. 1938
      xc_ppf1901.uvopt
  11. 14
      xc_ppf1901.uvproj

2
.gitignore

@ -3,3 +3,5 @@ build
*.dep
*.taoism
.swp
xc_ppf1901.uvgui*
xc_ppf1901.uvopt

4
cmsis/src/startup_stm32f429_439xx.s

@ -38,7 +38,7 @@
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000400
Stack_Size EQU 0x00002000
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
@ -49,7 +49,7 @@ __initial_sp
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
Heap_Size EQU 0x00002000
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base

212
target/cmd.c

@ -0,0 +1,212 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdint.h>
#include "cmd.h"
#define MAX_HISTORY (4)
#define CMDBUF_SIZE (256)
enum KEY_ACTION{
KEY_NULL = 0, /* NULL */
CTRL_A = 1, /* Ctrl+a */
CTRL_B = 2, /* Ctrl-b */
CTRL_C = 3, /* Ctrl-c */
CTRL_D = 4, /* Ctrl-d */
CTRL_E = 5, /* Ctrl-e */
CTRL_F = 6, /* Ctrl-f */
CTRL_H = 8, /* Ctrl-h */
TAB = 9, /* Tab */
CTRL_K = 11, /* Ctrl+k */
CTRL_L = 12, /* Ctrl+l */
ENTER = 13, /* Enter */
CTRL_N = 14, /* Ctrl-n */
CTRL_P = 16, /* Ctrl-p */
CTRL_T = 20, /* Ctrl-t */
CTRL_U = 21, /* Ctrl+u */
CTRL_W = 23, /* Ctrl+w */
ESC = 27, /* Escape */
BACKSPACE = 127 /* Backspace */
};
static int maxargs = 4;
static char cmdbuf[CMDBUF_SIZE];
static int bufidx;
static int do_help(cmd_tbl_t s, int argc, char *argv[]);
CON_CMD(help, 0, "commands help", do_help)
static struct cmd_tbl_s *__cmds[] = {
&__con_cmd_help,
NULL
};
static int do_help(cmd_tbl_t s, int argc, char *argv[])
{
cmd_tbl_t it = __cmds[0];
printf("support commands:\r\n\r\n");
while (it) {
printf("%s\t%s\r\n", it->name, it->help);
++it;
}
return 0;
}
int cmd_init()
{
cmd_tbl_t it = __cmds[0];
while (it) {
if (it->maxargs > maxargs)
maxargs = it->maxargs + 1;
++it;
}
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
return 0;
}
static int32_t parse_line(char *cmd, uint32_t len, char *argv[], int _maxargs)
{
uint32_t argc;
char *p;
uint32_t position;
/* Init params */
p = cmd;
position = 0;
argc = 0;
while ((position < len) && (argc < _maxargs)) {
/* Skip all blanks */
while (((char)(*p) == ' ') && (position < len)) {
*p = '\0';
p++;
position++;
}
/* Process begin of a string */
if (*p == '"') {
p++;
position++;
argv[argc] = p;
argc++;
/* Skip this string */
while ((*p != '"') && (position < len)) {
p++;
position++;
}
/* Skip '"' */
*p = '\0';
p++;
position++;
} else {/* Normal char */
argv[argc] = p;
argc++;
while (((char)*p != ' ') && ((char)*p != '\t') && (position < len)) {
p++;
position++;
}
}
}
return argc;
}
int cmd_process(char *line)
{
cmd_tbl_t it = __cmds[0];
int i, argc, namelen;
int size = strlen(line);
char *argv[maxargs];
/* split line */
for (i = 0; i < maxargs; ++i) {
argv[i] = NULL;
}
argc = parse_line(line, size, argv, maxargs);
if (argc <= 0)
goto recovery;
while (it) {
namelen = strlen(it->name);
if (strncasecmp(argv[0], it->name, namelen) == 0) {
it->cmd(it, argc, argv);
return 1;
}
++it;
}
/* recovery line */
recovery:
for (i = 0; i < size; ++i) {
if (line[i] == '\0')
line[i] = ' ';
}
return 0;
}
void cmd_loop()
{
char c;
int n;
do {
c = fgetc(stdin);
if (c <= 0)
break;
if (bufidx >= CMDBUF_SIZE) {
printf("too long\r\n");
bufidx = 0;
printf("\r\n> ");
}
switch (c) {
case CTRL_C:
bufidx = 0;
printf("\r\n> ");
return;
case BACKSPACE:
case CTRL_H:
if (bufidx > 0) {
printf("\b \b");
bufidx--;
cmdbuf[bufidx] = '\0';
}
return;
case CTRL_L:
printf("\x1b[H\x1b[2J> ");
if (bufidx > 0) {
for (n = 0; n < bufidx; ++n) {
fputc(cmdbuf[n], stdout);
}
}
return;
}
/* end of line */
if (c == '\r' || c == '\n') {
printf("\r\n");
if (bufidx > 0) {
cmdbuf[bufidx] = '\0';
cmd_process(cmdbuf);
printf("\r\n");
bufidx = 0;
}
printf("> ");
continue;
}
if (isprint(c)) {
cmdbuf[bufidx++] = c;
fputc(c, stdout);
}
} while (1) ;
}

31
target/cmd.h

@ -0,0 +1,31 @@
#ifndef __CMD_H__
#define __CMD_H__
#ifdef __cplusplus
extern "C" {
#endif
struct cmd_tbl_s {
const char *name;
const char *help;
int maxargs;
int (*cmd)(struct cmd_tbl_s *, int argc, char *argv[]);
};
typedef struct cmd_tbl_s *cmd_tbl_t;
#define CON_CMD(name, maxarg, usage, handler) \
struct cmd_tbl_s __con_cmd_##name __attribute__((unused, section(".cmdline_cmd"))) = \
{ #name, usage, maxarg, handler};
/* initialize command */
int cmd_init(void);
/* process debug console input */
void cmd_loop(void);
#ifdef __cplusplus
}
#endif
#endif

4
target/lowlevel.c

@ -4,6 +4,7 @@
#include "gpio.h"
#include "spi.h"
#include "tick.h"
#include "cmd.h"
void lowlevel_init()
{
@ -11,6 +12,8 @@ void lowlevel_init()
/* debug console */
serial_setup(&serial0, CONSOLE_BAUDRATE, 8, SERIAL_STOPBITS_1);
cmd_init();
gpio_init(WDI, GPIO_OUTPUT);
gpio_init(JPB1_VCC18_EN, GPIO_OUTPUT);
@ -33,6 +36,7 @@ void lowlevel_init()
gpio_set(CLK_MUX_PD);
gpio_init(SC18IS602_RST, GPIO_OUTPUT);
gpio_set(SC18IS602_RST);
spi_setup(&spi0, PA4, SPI_MODE_3);
ticks_init(TICKS_PERIOD);

3
target/main.c

@ -4,6 +4,7 @@
#include "eeprom.h"
#include "i2c.h"
#include "gpio.h"
#include "cmd.h"
i2c_t _i2c;
int main()
@ -23,6 +24,6 @@ int main()
printf("running\r\n...............................\r\n> ");
while (1) {
iwdg_reset();
cmd_loop();
}
}

4
target/retarget.c

@ -8,7 +8,7 @@ int fputc(int c, FILE *f)
{
uint8_t ch = c;
if ((f == stdout) || (f == stderr)) {
return serial_send_buffered(&serial0, &ch, 1);
return serial_send_buffered(CONSOLE_SERIAL, &ch, 1);
}
return 0;
}
@ -18,7 +18,7 @@ int fgetc(FILE *f)
int c = -1;
if (f == stdin) {
serial_recv_buffered(&serial0, (uint8_t *)&c, 1);
serial_recv_buffered(CONSOLE_SERIAL, (uint8_t *)&c, 1);
}
return c;
}

1
target/target.h

@ -8,6 +8,7 @@
#define APP_ADDRESS (0x08008000)
#define TICKS_PERIOD (2) /* mill seconds */
#define CONSOLE_SERIAL (&serial0)
#define CONSOLE_BAUDRATE (115200)
#define TARGET_HEAP_SIZE (0x200000)

34
xc_ppf1901.sct

@ -0,0 +1,34 @@
FLASH 0x08000000 0x200000
{
EXEC_ROM 0x08000000 0x200000
{
startup_stm32f429_439xx.o(RESET, +FIRST)
*(+RO)
}
}
CCM 0x10000000 0x10000
{
HEAP 0x10000000 0x2000
{
*(HEAP)
}
STACK 0x10002000 0xE000
{
*(STACK)
}
}
SRAM 0x20000000 0x30000
{
DATA_RAM 0x20000000 0x20000
{
*(+RW +ZI)
}
TXDMA 0x20020000 0x10000
{
serial.o(.txdma* +ZI)
}
}

1938
xc_ppf1901.uvopt

File diff suppressed because it is too large

14
xc_ppf1901.uvproj

@ -378,10 +378,10 @@
<useFile>0</useFile>
<TextAddressRange>0x08000000</TextAddressRange>
<DataAddressRange>0x20000000</DataAddressRange>
<ScatterFile></ScatterFile>
<ScatterFile>.\xc_ppf1901.sct</ScatterFile>
<IncludeLibs></IncludeLibs>
<IncludeLibsPath></IncludeLibsPath>
<Misc></Misc>
<Misc>--keep=startup_stm32f429_439xx.o(RESET)</Misc>
<LinkerInputFile></LinkerInputFile>
<DisabledWarnings></DisabledWarnings>
</LDads>
@ -946,6 +946,16 @@
<FileType>5</FileType>
<FilePath>.\target\target.h</FilePath>
</File>
<File>
<FileName>cmd.c</FileName>
<FileType>1</FileType>
<FilePath>.\target\cmd.c</FilePath>
</File>
<File>
<FileName>cmd.h</FileName>
<FileType>5</FileType>
<FilePath>.\target\cmd.h</FilePath>
</File>
</Files>
</Group>
</Groups>

Loading…
Cancel
Save