Browse Source

fix lib/serial.c buffer section definitions

Signed-off-by: surenyi <surenyi82@163.com>
master
surenyi 6 years ago
parent
commit
cc413c8fed
  1. 8
      lib/a3k.c
  2. 24
      lib/a3k.h
  3. 42
      lib/serial.c
  4. 2
      src/config.h
  5. 27
      src/flash.ld
  6. 14
      src/iap.lds
  7. 2
      src/main.c

8
lib/a3k.c

@ -903,7 +903,7 @@ void a3k_close(a3k_t tag)
serial_close(tag->uart);
}
#ifdef TARGET_HAS_A3K_0
#if (TARGET_HAS_A3K_0)
struct a3k_tag a3k0 = {
.uart = &serial1,
.rst = PF10,
@ -918,7 +918,7 @@ struct a3k_tag a3k0 = {
};
#endif
#ifdef TARGET_HAS_A3K_1
#if TARGET_HAS_A3K_1
struct a3k_tag a3k1 = {
.uart = &serial2,
.rst = PI14,
@ -933,14 +933,14 @@ struct a3k_tag a3k1 = {
};
#endif
#ifdef TARGET_HAS_A3K_2
#if TARGET_HAS_A3K_2
struct a3k_tag a3k2 = {
.uart = &serial3,
.pseudo = 1,
};
#endif
#ifdef TARGET_HAS_A3K_3
#if TARGET_HAS_A3K_3
struct a3k_tag a3k3 = {
.uart = &serial5,
.pseudo = 1,

24
lib/a3k.h

@ -9,6 +9,22 @@ extern "C" {
#include "config.h"
#ifndef TARGET_HAS_A3K_0
#define TARGET_HAS_A3K_0 0
#endif
#ifndef TARGET_HAS_A3K_1
#define TARGET_HAS_A3K_1 0
#endif
#ifndef TARGET_HAS_A3K_2
#define TARGET_HAS_A3K_2 0
#endif
#ifndef TARGET_HAS_A3K_3
#define TARGET_HAS_A3K_3 0
#endif
#define A3K_UART_BAUDRATE (460800)
#define FORMAT3KBLEN (350)
@ -32,19 +48,19 @@ int a3k_putpacket(a3k_t tag, const void *_ptr, int len);
void a3k_discardpacket(a3k_t tag);
#ifdef TARGET_HAS_A3K_0
#if (TARGET_HAS_A3K_0)
extern struct a3k_tag a3k0;
#endif
#ifdef TARGET_HAS_A3K_1
#if (TARGET_HAS_A3K_1)
extern struct a3k_tag a3k1;
#endif
#ifdef TARGET_HAS_A3K_2
#if (TARGET_HAS_A3K_2)
extern struct a3k_tag a3k2;
#endif
#ifdef TARGET_HAS_A3K_3
#if (TARGET_HAS_A3K_3)
extern struct a3k_tag a3k3;
#endif

42
lib/serial.c

@ -394,9 +394,9 @@ static void usart1_setup(struct serial *uart)
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1);
}
static volatile uint8_t __usart1_rx_buffer[TARGET_USART1_RX_BUFFER_SIZE] __attribute__((section(".rxdma.usart1")));
static volatile uint8_t __usart1_tx_buffer[TARGET_USART1_TX_BUFFER_SIZE] __attribute__((section(".txbuf.usart1")));
static volatile uint8_t __usart1_tx_dma_buffer[TX_DMA_BUFFER_SIZE] __attribute__((section(".txdma.usart1")));
static volatile uint8_t __usart1_rx_buffer[TARGET_USART1_RX_BUFFER_SIZE] __attribute__((section(".rxdma.usart1,\"aw\",%nobits@")));
static volatile uint8_t __usart1_tx_buffer[TARGET_USART1_TX_BUFFER_SIZE] __attribute__((section(".txbuf.usart1,\"aw\",%nobits@")));
static volatile uint8_t __usart1_tx_dma_buffer[TX_DMA_BUFFER_SIZE] __attribute__((section(".txdma.usart1,\"aw\",%nobits@")));
struct serial serial0 = {
.name = "USART1",
@ -456,9 +456,9 @@ static void usart2_setup(struct serial *uart)
GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_USART2);
}
static volatile uint8_t __usart2_rx_buffer[TARGET_USART2_RX_BUFFER_SIZE] __attribute__((section(".rxdma.usart2")));
static volatile uint8_t __usart2_tx_buffer[TARGET_USART2_TX_BUFFER_SIZE] __attribute__((section(".txbuf.usart2")));
static volatile uint8_t __usart2_tx_dma_buffer[TX_DMA_BUFFER_SIZE] __attribute__((section(".txdma.usart2")));
static volatile uint8_t __usart2_rx_buffer[TARGET_USART2_RX_BUFFER_SIZE] __attribute__((section(".rxdma.usart2,\"aw\",%nobits@")));
static volatile uint8_t __usart2_tx_buffer[TARGET_USART2_TX_BUFFER_SIZE] __attribute__((section(".txbuf.usart2,\"aw\",%nobits@")));
static volatile uint8_t __usart2_tx_dma_buffer[TX_DMA_BUFFER_SIZE] __attribute__((section(".txdma.usart2,\"aw\",%nobits@")));
struct serial serial1 = {
.name = "USART2",
@ -518,9 +518,9 @@ static void usart3_setup(struct serial *uart)
GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_USART3);
}
static volatile uint8_t __usart3_rx_buffer[TARGET_USART3_RX_BUFFER_SIZE] __attribute__((section(".rxdma.usart3")));
static volatile uint8_t __usart3_tx_buffer[TARGET_USART3_TX_BUFFER_SIZE] __attribute__((section(".txdma.usart3")));
static volatile uint8_t __usart3_tx_dma_buffer[TX_DMA_BUFFER_SIZE] __attribute__((section(".txbuf.usart3")));
static volatile uint8_t __usart3_rx_buffer[TARGET_USART3_RX_BUFFER_SIZE] __attribute__((section(".rxdma.usart3,\"aw\",%nobits@")));
static volatile uint8_t __usart3_tx_buffer[TARGET_USART3_TX_BUFFER_SIZE] __attribute__((section(".txbuf.usart3,\"aw\",%nobits@")));
static volatile uint8_t __usart3_tx_dma_buffer[TX_DMA_BUFFER_SIZE] __attribute__((section(".txdma.usart3,\"aw\",%nobits@")));
struct serial serial2 = {
.name = "USART3",
@ -579,9 +579,9 @@ static void usart4_setup(struct serial *uart)
GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_UART4);
}
static volatile uint8_t __usart4_rx_buffer[TARGET_USART4_RX_BUFFER_SIZE] __attribute__((section(".rxdma.usart4")));
static volatile uint8_t __usart4_tx_buffer[TARGET_USART4_TX_BUFFER_SIZE] __attribute__((section(".txbuf.usart4")));
static volatile uint8_t __usart4_tx_dma_buffer[TX_DMA_BUFFER_SIZE] __attribute__((section(".txdma.usart4")));
static volatile uint8_t __usart4_rx_buffer[TARGET_USART4_RX_BUFFER_SIZE] __attribute__((section(".rxdma.usart4,\"aw\",%nobits@")));
static volatile uint8_t __usart4_tx_buffer[TARGET_USART4_TX_BUFFER_SIZE] __attribute__((section(".txbuf.usart4,\"aw\",%nobits@")));
static volatile uint8_t __usart4_tx_dma_buffer[TX_DMA_BUFFER_SIZE] __attribute__((section(".txdma.usart4,\"aw\",%nobits@")));
struct serial serial3 = {
.name = "UART4",
@ -650,9 +650,9 @@ static void usart5_setup(struct serial *uart)
GPIO_PinAFConfig(GPIOD, GPIO_PinSource2, GPIO_AF_UART5);
}
static volatile uint8_t __usart5_rx_buffer[TARGET_USART5_RX_BUFFER_SIZE] __attribute__((section(".rxdma.usart5")));
static volatile uint8_t __usart5_tx_buffer[TARGET_USART5_TX_BUFFER_SIZE] __attribute__((section(".txbuf.usart5")));
static volatile uint8_t __usart5_tx_dma_buffer[TX_DMA_BUFFER_SIZE] __attribute__((section(".txdma.usart5")));
static volatile uint8_t __usart5_rx_buffer[TARGET_USART5_RX_BUFFER_SIZE] __attribute__((section(".rxdma.usart5,\"aw\",%nobits@")));
static volatile uint8_t __usart5_tx_buffer[TARGET_USART5_TX_BUFFER_SIZE] __attribute__((section(".txbuf.usart5,\"aw\",%nobits@")));
static volatile uint8_t __usart5_tx_dma_buffer[TX_DMA_BUFFER_SIZE] __attribute__((section(".txdma.usart5,\"aw\",%nobits@")));
struct serial serial4 = {
.name = "USART5",
@ -714,9 +714,9 @@ static void usart6_setup(struct serial *uart)
GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_USART6);
}
static volatile uint8_t __usart6_rx_buffer[TARGET_USART6_RX_BUFFER_SIZE] __attribute__((section(".rxdma.usart6")));
static volatile uint8_t __usart6_tx_buffer[TARGET_USART6_TX_BUFFER_SIZE] __attribute__((section(".txbuf.usart6")));
static volatile uint8_t __usart6_tx_dma_buffer[TX_DMA_BUFFER_SIZE] __attribute__((section(".txdma.usart6")));
static volatile uint8_t __usart6_rx_buffer[TARGET_USART6_RX_BUFFER_SIZE] __attribute__((section(".rxdma.usart6,\"aw\",%nobits@")));
static volatile uint8_t __usart6_tx_buffer[TARGET_USART6_TX_BUFFER_SIZE] __attribute__((section(".txbuf.usart6,\"aw\",%nobits@")));
static volatile uint8_t __usart6_tx_dma_buffer[TX_DMA_BUFFER_SIZE] __attribute__((section(".txdma.usart6,\"aw\",%nobits@")));
struct serial serial5 = {
.name = "USART6",
@ -777,9 +777,9 @@ static void usart7_setup(struct serial *uart)
GPIO_PinAFConfig(GPIOF, GPIO_PinSource7, GPIO_AF_UART7);
}
static volatile uint8_t __usart7_rx_buffer[TARGET_USART7_RX_BUFFER_SIZE] __attribute__((section(".rxdma.usart7")));
static volatile uint8_t __usart7_tx_buffer[TARGET_USART7_TX_BUFFER_SIZE] __attribute__((section(".txbuf.usart7")));
static volatile uint8_t __usart7_tx_dma_buffer[TX_DMA_BUFFER_SIZE] __attribute__((section(".txdma.usart7")));
static volatile uint8_t __usart7_rx_buffer[TARGET_USART7_RX_BUFFER_SIZE] __attribute__((section(".rxdma.usart7,\"aw\",%nobits@")));
static volatile uint8_t __usart7_tx_buffer[TARGET_USART7_TX_BUFFER_SIZE] __attribute__((section(".txbuf.usart7,\"aw\",%nobits@")));
static volatile uint8_t __usart7_tx_dma_buffer[TX_DMA_BUFFER_SIZE] __attribute__((section(".txdma.usart7,\"aw\",%nobits@")));
struct serial serial6 = {
.name = "USART7",

2
src/config.h

@ -1,7 +1,7 @@
#ifndef __TARGET_CONFIG_H__
#define __TARGET_CONFIG_H__
#define APP_ADDRESS (0x08080000)
#define APP_ADDRESS (0x08004000)
#define CONSOLE_BAUDRATE (115200)
#define RS422_BAUDRATE (115200)

27
src/flash.ld

@ -68,16 +68,6 @@ SECTIONS {
__cmdline_cmd_end = .;
} > flash
.txdma : {
. = ALIGN(0x4);
*(.txdma.*)
} > ram2 AT> flash
.rxdma : {
. = ALIGN(0x4);
*(.rxdma.*)
} > ram3 AT> flash
_sidata = LOADADDR(.data);
.data : {
. = ALIGN(4);
@ -88,7 +78,6 @@ SECTIONS {
_edata = .;
} >ram1 AT> flash
_siccmram = LOADADDR(.ccmram);
.ccmram : {
. = ALIGN(4);
@ -100,6 +89,7 @@ SECTIONS {
_eccmram = .;
} >ccmram AT> flash
. = ALIGN(4);
.bss : {
_sbss = .;
__bss_start__ = _sbss;
@ -110,6 +100,10 @@ SECTIONS {
_ebss = .;
__bss_end__ = _ebss;
} > ram1
.txbuf : {
*(.txbuf.*)
} > ram1
._user_heap_stack : {
. = ALIGN(4);
PROVIDE ( end = . );
@ -117,6 +111,17 @@ SECTIONS {
. = . + _MIN_STACK_SIZE;
. = ALIGN(4);
} > ram1
.txdma : {
. = ALIGN(0x4);
*(.txdma.*)
} > ram2
.rxdma : {
. = ALIGN(0x4);
*(.rxdma.*)
} > ram3
/DISCARD/ : { *(.eh_frame) }
/DISCARD/ : {
libc.a ( * )

14
src/iap.lds

@ -97,6 +97,19 @@ SECTIONS {
_ebss = .;
__bss_end__ = _ebss;
} > ram
.txbuf : {
*(.txbuf.*)
} > ram
.txdma : {
*(.txdma.*)
} > ram
.rxdma : {
*(.rxdma.*)
} > ram
._user_heap_stack : {
. = ALIGN(4);
PROVIDE ( end = . );
@ -105,6 +118,7 @@ SECTIONS {
. = . + _MIN_STACK_SIZE;
. = ALIGN(4);
} > ram
/DISCARD/ : { *(.eh_frame) }
/DISCARD/ : {
libc.a ( * )

2
src/main.c

@ -334,7 +334,7 @@ static int decode_packet(a3k_t to, struct frames *f)
ring = &f->slices[pos];
if (ring->len > 0) {
a3k_putpacket(to, ring->rb, ring->len);
rb->len = 0;
ring->len = 0;
}
return 1;
}

Loading…
Cancel
Save