mirror of https://github.com/ARMmbed/mbed-os.git
Enable asynchronous communications
parent
1df975a3a5
commit
8a6d2b0835
|
@ -71,8 +71,12 @@ extern uint32_t Image$$VECTORS$$Base;
|
||||||
extern uint32_t Image$$RO_DATA$$Base;
|
extern uint32_t Image$$RO_DATA$$Base;
|
||||||
extern uint32_t Image$$RW_DATA$$Base;
|
extern uint32_t Image$$RW_DATA$$Base;
|
||||||
extern uint32_t Image$$ZI_DATA$$Base;
|
extern uint32_t Image$$ZI_DATA$$Base;
|
||||||
|
#if !defined ( __ICCARM__ )
|
||||||
extern uint32_t Image$$TTB$$ZI$$Base;
|
extern uint32_t Image$$TTB$$ZI$$Base;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined( __CC_ARM )
|
#if defined( __CC_ARM )
|
||||||
|
#elif defined( __ICCARM__ )
|
||||||
#else
|
#else
|
||||||
extern uint32_t Image$$RW_DATA_NC$$Base;
|
extern uint32_t Image$$RW_DATA_NC$$Base;
|
||||||
extern uint32_t Image$$ZI_DATA_NC$$Base;
|
extern uint32_t Image$$ZI_DATA_NC$$Base;
|
||||||
|
@ -88,10 +92,18 @@ extern uint32_t Image$$RW_DATA_NC$$Limit;
|
||||||
extern uint32_t Image$$ZI_DATA_NC$$Limit;
|
extern uint32_t Image$$ZI_DATA_NC$$Limit;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined( __ICCARM__ )
|
||||||
|
#define VECTORS_SIZE (((uint32_t)Image$$VECTORS$$Limit >> 20) - ((uint32_t)Image$$VECTORS$$Base >> 20) + 1)
|
||||||
|
#define RO_DATA_SIZE (((uint32_t)Image$$RO_DATA$$Limit >> 20) - ((uint32_t)Image$$RO_DATA$$Base >> 20) + 1)
|
||||||
|
#define RW_DATA_SIZE (((uint32_t)Image$$RW_DATA$$Limit >> 20) - ((uint32_t)Image$$RW_DATA$$Base >> 20) + 1)
|
||||||
|
#define ZI_DATA_SIZE (((uint32_t)Image$$ZI_DATA$$Limit >> 20) - ((uint32_t)Image$$ZI_DATA$$Base >> 20) + 1)
|
||||||
|
#else
|
||||||
#define VECTORS_SIZE (((uint32_t)&Image$$VECTORS$$Limit >> 20) - ((uint32_t)&Image$$VECTORS$$Base >> 20) + 1)
|
#define VECTORS_SIZE (((uint32_t)&Image$$VECTORS$$Limit >> 20) - ((uint32_t)&Image$$VECTORS$$Base >> 20) + 1)
|
||||||
#define RO_DATA_SIZE (((uint32_t)&Image$$RO_DATA$$Limit >> 20) - ((uint32_t)&Image$$RO_DATA$$Base >> 20) + 1)
|
#define RO_DATA_SIZE (((uint32_t)&Image$$RO_DATA$$Limit >> 20) - ((uint32_t)&Image$$RO_DATA$$Base >> 20) + 1)
|
||||||
#define RW_DATA_SIZE (((uint32_t)&Image$$RW_DATA$$Limit >> 20) - ((uint32_t)&Image$$RW_DATA$$Base >> 20) + 1)
|
#define RW_DATA_SIZE (((uint32_t)&Image$$RW_DATA$$Limit >> 20) - ((uint32_t)&Image$$RW_DATA$$Base >> 20) + 1)
|
||||||
#define ZI_DATA_SIZE (((uint32_t)&Image$$ZI_DATA$$Limit >> 20) - ((uint32_t)&Image$$ZI_DATA$$Base >> 20) + 1)
|
#define ZI_DATA_SIZE (((uint32_t)&Image$$ZI_DATA$$Limit >> 20) - ((uint32_t)&Image$$ZI_DATA$$Base >> 20) + 1)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined( __CC_ARM )
|
#if defined( __CC_ARM )
|
||||||
#else
|
#else
|
||||||
#define RW_DATA_NC_SIZE (((uint32_t)&Image$$RW_DATA_NC$$Limit >> 20) - ((uint32_t)&Image$$RW_DATA_NC$$Base >> 20) + 1)
|
#define RW_DATA_NC_SIZE (((uint32_t)&Image$$RW_DATA_NC$$Limit >> 20) - ((uint32_t)&Image$$RW_DATA_NC$$Base >> 20) + 1)
|
||||||
|
@ -106,16 +118,44 @@ static uint32_t Sect_Normal_RW; //as Sect_Normal_Cod, but writeable and not exe
|
||||||
static uint32_t Sect_Normal_SH; //as Sect_Normal_Cod, but writeable and shareable
|
static uint32_t Sect_Normal_SH; //as Sect_Normal_Cod, but writeable and shareable
|
||||||
static uint32_t Sect_Device_RO; //device, non-shareable, non-executable, ro, domain 0, base addr 0
|
static uint32_t Sect_Device_RO; //device, non-shareable, non-executable, ro, domain 0, base addr 0
|
||||||
static uint32_t Sect_Device_RW; //as Sect_Device_RO, but writeable
|
static uint32_t Sect_Device_RW; //as Sect_Device_RO, but writeable
|
||||||
|
|
||||||
/* Define global descriptors */
|
/* Define global descriptors */
|
||||||
static uint32_t Page_L1_4k = 0x0; //generic
|
static uint32_t Page_L1_4k = 0x0; //generic
|
||||||
static uint32_t Page_L1_64k = 0x0; //generic
|
static uint32_t Page_L1_64k = 0x0; //generic
|
||||||
static uint32_t Page_4k_Device_RW; //Shared device, not executable, rw, domain 0
|
static uint32_t Page_4k_Device_RW; //Shared device, not executable, rw, domain 0
|
||||||
static uint32_t Page_64k_Device_RW; //Shared device, not executable, rw, domain 0
|
static uint32_t Page_64k_Device_RW; //Shared device, not executable, rw, domain 0
|
||||||
|
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
__no_init uint32_t Image$$TTB$$ZI$$Base @ ".retram";
|
||||||
|
uint32_t Image$$VECTORS$$Base;
|
||||||
|
uint32_t Image$$RO_DATA$$Base;
|
||||||
|
uint32_t Image$$RW_DATA$$Base;
|
||||||
|
uint32_t Image$$ZI_DATA$$Base;
|
||||||
|
|
||||||
|
uint32_t Image$$VECTORS$$Limit;
|
||||||
|
uint32_t Image$$RO_DATA$$Limit;
|
||||||
|
uint32_t Image$$RW_DATA$$Limit;
|
||||||
|
uint32_t Image$$ZI_DATA$$Limit;
|
||||||
|
#endif
|
||||||
|
|
||||||
void create_translation_table(void)
|
void create_translation_table(void)
|
||||||
{
|
{
|
||||||
mmu_region_attributes_Type region;
|
mmu_region_attributes_Type region;
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
#pragma section=".intvec"
|
||||||
|
#pragma section=".rodata"
|
||||||
|
#pragma section=".rwdata"
|
||||||
|
#pragma section=".bss"
|
||||||
|
|
||||||
|
Image$$VECTORS$$Base = (uint32_t) __section_begin(".intvec");
|
||||||
|
Image$$VECTORS$$Limit= ((uint32_t)__section_begin(".intvec")+(uint32_t)__section_size(".intvec"));
|
||||||
|
Image$$RO_DATA$$Base = (uint32_t) __section_begin(".rodata");
|
||||||
|
Image$$RO_DATA$$Limit= ((uint32_t)__section_begin(".rodata")+(uint32_t)__section_size(".rodata"));
|
||||||
|
Image$$RW_DATA$$Base = (uint32_t) __section_begin(".rwdata");
|
||||||
|
Image$$RW_DATA$$Limit= ((uint32_t)__section_begin(".rwdata")+(uint32_t)__section_size(".rwdata"));
|
||||||
|
Image$$ZI_DATA$$Base = (uint32_t) __section_begin(".bss");
|
||||||
|
Image$$ZI_DATA$$Limit= ((uint32_t)__section_begin(".bss")+(uint32_t)__section_size(".bss"));
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
* Generate descriptors. Refer to MBRZA1H.h to get information about attributes
|
* Generate descriptors. Refer to MBRZA1H.h to get information about attributes
|
||||||
*
|
*
|
||||||
|
@ -158,13 +198,25 @@ void create_translation_table(void)
|
||||||
__TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_PERIPH_BASE0 , 3, Sect_Device_RW);
|
__TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_PERIPH_BASE0 , 3, Sect_Device_RW);
|
||||||
__TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_PERIPH_BASE1 , 49, Sect_Device_RW);
|
__TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_PERIPH_BASE1 , 49, Sect_Device_RW);
|
||||||
|
|
||||||
|
#if defined( __ICCARM__ )
|
||||||
|
//Define Image
|
||||||
|
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)Image$$RO_DATA$$Base, RO_DATA_SIZE, Sect_Normal_RO);
|
||||||
|
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)Image$$VECTORS$$Base, VECTORS_SIZE, Sect_Normal_Cod);
|
||||||
|
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)Image$$RW_DATA$$Base, RW_DATA_SIZE, Sect_Normal_RW);
|
||||||
|
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)Image$$ZI_DATA$$Base, ZI_DATA_SIZE, Sect_Normal_SH);
|
||||||
|
#else
|
||||||
//Define Image
|
//Define Image
|
||||||
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$RO_DATA$$Base, RO_DATA_SIZE, Sect_Normal_RO);
|
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$RO_DATA$$Base, RO_DATA_SIZE, Sect_Normal_RO);
|
||||||
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$VECTORS$$Base, VECTORS_SIZE, Sect_Normal_Cod);
|
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$VECTORS$$Base, VECTORS_SIZE, Sect_Normal_Cod);
|
||||||
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$RW_DATA$$Base, RW_DATA_SIZE, Sect_Normal_RW);
|
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$RW_DATA$$Base, RW_DATA_SIZE, Sect_Normal_RW);
|
||||||
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$ZI_DATA$$Base, ZI_DATA_SIZE, Sect_Normal_SH);
|
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$ZI_DATA$$Base, ZI_DATA_SIZE, Sect_Normal_RW);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined( __CC_ARM )
|
#if defined( __CC_ARM )
|
||||||
__TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_ONCHIP_SRAM_NC_BASE, 10, Sect_Normal_NC);
|
__TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_ONCHIP_SRAM_NC_BASE, 10, Sect_Normal_NC);
|
||||||
|
#elif defined ( __ICCARM__ )
|
||||||
|
__TTSection (&Image$$TTB$$ZI$$Base, Renesas_RZ_A1_ONCHIP_SRAM_NC_BASE, 10, Sect_Normal_NC);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$RW_DATA_NC$$Base, RW_DATA_NC_SIZE, Sect_Normal_NC);
|
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$RW_DATA_NC$$Base, RW_DATA_NC_SIZE, Sect_Normal_NC);
|
||||||
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$ZI_DATA_NC$$Base, ZI_DATA_NC_SIZE, Sect_Normal_NC);
|
__TTSection (&Image$$TTB$$ZI$$Base, (uint32_t)&Image$$ZI_DATA_NC$$Base, ZI_DATA_NC_SIZE, Sect_Normal_NC);
|
||||||
|
|
|
@ -62,9 +62,9 @@
|
||||||
|
|
||||||
#define DEVICE_DEBUG_AWARENESS 0
|
#define DEVICE_DEBUG_AWARENESS 0
|
||||||
|
|
||||||
#define DEVICE_STDIO_MESSAGES 0
|
#define DEVICE_STDIO_MESSAGES 1
|
||||||
|
|
||||||
#define DEVICE_ERROR_PATTERN 0
|
#define DEVICE_ERROR_PATTERN 1
|
||||||
|
|
||||||
#include "objects.h"
|
#include "objects.h"
|
||||||
#include "dma_api.h"
|
#include "dma_api.h"
|
||||||
|
|
|
@ -602,7 +602,11 @@ int serial_getc(serial_t *obj) {
|
||||||
int data;
|
int data;
|
||||||
int was_masked;
|
int was_masked;
|
||||||
|
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
was_masked = __disable_irq_iar();
|
||||||
|
#else
|
||||||
was_masked = __disable_irq();
|
was_masked = __disable_irq();
|
||||||
|
#endif /* __ICCARM__ */
|
||||||
if (obj->serial.uart->SCFSR & 0x93) {
|
if (obj->serial.uart->SCFSR & 0x93) {
|
||||||
err_read = obj->serial.uart->SCFSR;
|
err_read = obj->serial.uart->SCFSR;
|
||||||
obj->serial.uart->SCFSR = (err_read & ~0x93);
|
obj->serial.uart->SCFSR = (err_read & ~0x93);
|
||||||
|
@ -619,7 +623,11 @@ int serial_getc(serial_t *obj) {
|
||||||
while (!serial_readable(obj));
|
while (!serial_readable(obj));
|
||||||
data = obj->serial.uart->SCFRDR & 0xff;
|
data = obj->serial.uart->SCFRDR & 0xff;
|
||||||
|
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
was_masked = __disable_irq_iar();
|
||||||
|
#else
|
||||||
was_masked = __disable_irq();
|
was_masked = __disable_irq();
|
||||||
|
#endif /* __ICCARM__ */
|
||||||
err_read = obj->serial.uart->SCFSR;
|
err_read = obj->serial.uart->SCFSR;
|
||||||
obj->serial.uart->SCFSR = (err_read & 0xfffD); // Clear RDF
|
obj->serial.uart->SCFSR = (err_read & 0xfffD); // Clear RDF
|
||||||
if (!was_masked) {
|
if (!was_masked) {
|
||||||
|
@ -636,7 +644,11 @@ static void serial_put_prepare(serial_t *obj)
|
||||||
{
|
{
|
||||||
int was_masked;
|
int was_masked;
|
||||||
|
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
was_masked = __disable_irq_iar();
|
||||||
|
#else
|
||||||
was_masked = __disable_irq();
|
was_masked = __disable_irq();
|
||||||
|
#endif /* __ICCARM__ */
|
||||||
obj->serial.uart->SCSCR |= 0x0080; // Set TIE
|
obj->serial.uart->SCSCR |= 0x0080; // Set TIE
|
||||||
if (!was_masked) {
|
if (!was_masked) {
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
|
@ -655,7 +667,11 @@ static void serial_put_done(serial_t *obj)
|
||||||
{
|
{
|
||||||
int was_masked;
|
int was_masked;
|
||||||
uint16_t dummy_read;
|
uint16_t dummy_read;
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
was_masked = __disable_irq_iar();
|
||||||
|
#else
|
||||||
was_masked = __disable_irq();
|
was_masked = __disable_irq();
|
||||||
|
#endif /* __ICCARM__ */
|
||||||
dummy_read = obj->serial.uart->SCFSR;
|
dummy_read = obj->serial.uart->SCFSR;
|
||||||
obj->serial.uart->SCFSR = (dummy_read & 0xff9f); // Clear TEND/TDFE
|
obj->serial.uart->SCFSR = (dummy_read & 0xff9f); // Clear TEND/TDFE
|
||||||
if (!was_masked) {
|
if (!was_masked) {
|
||||||
|
@ -673,7 +689,11 @@ int serial_writable(serial_t *obj) {
|
||||||
|
|
||||||
void serial_clear(serial_t *obj) {
|
void serial_clear(serial_t *obj) {
|
||||||
int was_masked;
|
int was_masked;
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
was_masked = __disable_irq_iar();
|
||||||
|
#else
|
||||||
was_masked = __disable_irq();
|
was_masked = __disable_irq();
|
||||||
|
#endif /* __ICCARM__ */
|
||||||
|
|
||||||
obj->serial.uart->SCFCR |= 0x06; // TFRST = 1, RFRST = 1
|
obj->serial.uart->SCFCR |= 0x06; // TFRST = 1, RFRST = 1
|
||||||
obj->serial.uart->SCFCR &= ~0x06; // TFRST = 0, RFRST = 0
|
obj->serial.uart->SCFCR &= ~0x06; // TFRST = 0, RFRST = 0
|
||||||
|
@ -690,7 +710,11 @@ void serial_pinout_tx(PinName tx) {
|
||||||
|
|
||||||
void serial_break_set(serial_t *obj) {
|
void serial_break_set(serial_t *obj) {
|
||||||
int was_masked;
|
int was_masked;
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
was_masked = __disable_irq_iar();
|
||||||
|
#else
|
||||||
was_masked = __disable_irq();
|
was_masked = __disable_irq();
|
||||||
|
#endif /* __ICCARM__ */
|
||||||
// TxD Output(L)
|
// TxD Output(L)
|
||||||
obj->serial.uart->SCSPTR &= ~0x0001u; // SPB2DT = 0
|
obj->serial.uart->SCSPTR &= ~0x0001u; // SPB2DT = 0
|
||||||
obj->serial.uart->SCSCR &= ~0x0020u; // TE = 0 (Output disable)
|
obj->serial.uart->SCSCR &= ~0x0020u; // TE = 0 (Output disable)
|
||||||
|
@ -701,7 +725,11 @@ void serial_break_set(serial_t *obj) {
|
||||||
|
|
||||||
void serial_break_clear(serial_t *obj) {
|
void serial_break_clear(serial_t *obj) {
|
||||||
int was_masked;
|
int was_masked;
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
was_masked = __disable_irq_iar();
|
||||||
|
#else
|
||||||
was_masked = __disable_irq();
|
was_masked = __disable_irq();
|
||||||
|
#endif /* __ICCARM__ */
|
||||||
obj->serial.uart->SCSCR |= 0x0020u; // TE = 1 (Output enable)
|
obj->serial.uart->SCSCR |= 0x0020u; // TE = 1 (Output enable)
|
||||||
obj->serial.uart->SCSPTR |= 0x0001u; // SPB2DT = 1
|
obj->serial.uart->SCSPTR |= 0x0001u; // SPB2DT = 1
|
||||||
if (!was_masked) {
|
if (!was_masked) {
|
||||||
|
@ -716,7 +744,11 @@ void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, Pi
|
||||||
serial_flow_irq_set(obj, 0);
|
serial_flow_irq_set(obj, 0);
|
||||||
|
|
||||||
if (type == FlowControlRTSCTS) {
|
if (type == FlowControlRTSCTS) {
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
was_masked = __disable_irq_iar();
|
||||||
|
#else
|
||||||
was_masked = __disable_irq();
|
was_masked = __disable_irq();
|
||||||
|
#endif /* __ICCARM__ */
|
||||||
obj->serial.uart->SCFCR = 0x0008u; // CTS/RTS enable
|
obj->serial.uart->SCFCR = 0x0008u; // CTS/RTS enable
|
||||||
if (!was_masked) {
|
if (!was_masked) {
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
|
@ -724,7 +756,11 @@ void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, Pi
|
||||||
pinmap_pinout(rxflow, PinMap_UART_RTS);
|
pinmap_pinout(rxflow, PinMap_UART_RTS);
|
||||||
pinmap_pinout(txflow, PinMap_UART_CTS);
|
pinmap_pinout(txflow, PinMap_UART_CTS);
|
||||||
} else {
|
} else {
|
||||||
|
#if defined ( __ICCARM__ )
|
||||||
|
was_masked = __disable_irq_iar();
|
||||||
|
#else
|
||||||
was_masked = __disable_irq();
|
was_masked = __disable_irq();
|
||||||
|
#endif /* __ICCARM__ */
|
||||||
obj->serial.uart->SCFCR = 0x0000u; // CTS/RTS diable
|
obj->serial.uart->SCFCR = 0x0000u; // CTS/RTS diable
|
||||||
if (!was_masked) {
|
if (!was_masked) {
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
|
|
Loading…
Reference in New Issue