git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4717 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
6f0d2fed0a
commit
798f17d3f2
|
@ -68,19 +68,4 @@ void __early_init(void) {
|
||||||
*/
|
*/
|
||||||
void boardInit(void) {
|
void boardInit(void) {
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
* Various initialization (temporary code).
|
|
||||||
*/
|
|
||||||
SIU.PCR[GPIO_LED1].R = 0x0300; /* OBE | IBE. */
|
|
||||||
SIU.PCR[GPIO_LED2].R = 0x0300; /* OBE | IBE. */
|
|
||||||
SIU.PCR[GPIO_LED3].R = 0x0300; /* OBE | IBE. */
|
|
||||||
SIU.PCR[GPIO_LED4].R = 0x0300; /* OBE | IBE. */
|
|
||||||
SIU.PCR[GPIO_BUTTON1].R = 0x0100; /* IBE. */
|
|
||||||
SIU.PCR[GPIO_BUTTON2].R = 0x0100; /* IBE. */
|
|
||||||
SIU.PCR[GPIO_BUTTON3].R = 0x0100; /* IBE. */
|
|
||||||
SIU.PCR[GPIO_BUTTON4].R = 0x0100; /* IBE. */
|
|
||||||
SIU.PCR[GPIO_SCI_A_TX].R = 0x0500; /* Primary | IBE. */
|
|
||||||
SIU.PCR[GPIO_SCI_A_RX].R = 0x0500; /* Primary | IBE. */
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,27 @@
|
||||||
* @name SPC560Pxx capabilities
|
* @name SPC560Pxx capabilities
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
/* LINFlex attributes.*/
|
||||||
|
#define SPC5_HAS_LINFLEX0 TRUE
|
||||||
|
#define SPC5_LINFLEX0_RXI_HANDLER vector79
|
||||||
|
#define SPC5_LINFLEX0_TXI_HANDLER vector80
|
||||||
|
#define SPC5_LINFLEX0_ERR_HANDLER vector81
|
||||||
|
#define SPC5_LINFLEX0_RXI_NUMBER 79
|
||||||
|
#define SPC5_LINFLEX0_TXI_NUMBER 80
|
||||||
|
#define SPC5_LINFLEX0_ERR_NUMBER 81
|
||||||
|
|
||||||
|
#define SPC5_HAS_LINFLEX1 TRUE
|
||||||
|
#define SPC5_LINFLEX1_RXI_HANDLER vector99
|
||||||
|
#define SPC5_LINFLEX1_TXI_HANDLER vector100
|
||||||
|
#define SPC5_LINFLEX1_ERR_HANDLER vector101
|
||||||
|
#define SPC5_LINFLEX1_RXI_NUMBER 99
|
||||||
|
#define SPC5_LINFLEX1_TXI_NUMBER 100
|
||||||
|
#define SPC5_LINFLEX1_ERR_NUMBER 101
|
||||||
|
|
||||||
|
#define SPC5_HAS_LINFLEX2 FALSE
|
||||||
|
|
||||||
|
#define SPC5_HAS_LINFLEX3 FALSE
|
||||||
|
|
||||||
/* SIU/SIUL attributes.*/
|
/* SIU/SIUL attributes.*/
|
||||||
#define SPC5_HAS_SIU FALSE
|
#define SPC5_HAS_SIU FALSE
|
||||||
#define SPC5_SIU_SUPPORTS_PORTS TRUE
|
#define SPC5_SIU_SUPPORTS_PORTS TRUE
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file SPC56x/serial_lld.c
|
* @file SPC5xx/serial_lld.c
|
||||||
* @brief SPC563 low level serial driver code.
|
* @brief SPC5xx low level serial driver code.
|
||||||
*
|
*
|
||||||
* @addtogroup SERIAL
|
* @addtogroup SERIAL
|
||||||
* @{
|
* @{
|
||||||
|
@ -36,19 +36,33 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief eSCI-A serial driver identifier.
|
* @brief LIINFlex-0 serial driver identifier.
|
||||||
*/
|
*/
|
||||||
#if USE_SPC563_ESCIA || defined(__DOXYGEN__)
|
#if SPC5_SERIAL_USE_LINFLEX0 || defined(__DOXYGEN__)
|
||||||
SerialDriver SD1;
|
SerialDriver SD1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief eSCI-B serial driver identifier.
|
* @brief LIINFlex-1 serial driver identifier.
|
||||||
*/
|
*/
|
||||||
#if USE_SPC563_ESCIB || defined(__DOXYGEN__)
|
#if SPC5_SERIAL_USE_LINFLEX1 || defined(__DOXYGEN__)
|
||||||
SerialDriver SD2;
|
SerialDriver SD2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LIINFlex-2 serial driver identifier.
|
||||||
|
*/
|
||||||
|
#if SPC5_SERIAL_USE_LINFLEX2 || defined(__DOXYGEN__)
|
||||||
|
SerialDriver SD3;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LIINFlex-3 serial driver identifier.
|
||||||
|
*/
|
||||||
|
#if SPC5_SERIAL_USE_LINFLEX3 || defined(__DOXYGEN__)
|
||||||
|
SerialDriver SD4;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver local variables. */
|
/* Driver local variables. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -58,7 +72,7 @@ SerialDriver SD2;
|
||||||
*/
|
*/
|
||||||
static const SerialConfig default_config = {
|
static const SerialConfig default_config = {
|
||||||
SERIAL_DEFAULT_BITRATE,
|
SERIAL_DEFAULT_BITRATE,
|
||||||
SD_MODE_NORMAL | SD_MODE_PARITY_NONE
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -66,48 +80,36 @@ static const SerialConfig default_config = {
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief eSCI initialization.
|
* @brief LINFlex initialization.
|
||||||
* @details This function must be invoked with interrupts disabled.
|
* @details This function must be invoked with interrupts disabled.
|
||||||
*
|
*
|
||||||
* @param[in] sdp pointer to a @p SerialDriver object
|
* @param[in] sdp pointer to a @p SerialDriver object
|
||||||
* @param[in] config the architecture-dependent serial driver configuration
|
* @param[in] config the architecture-dependent serial driver configuration
|
||||||
*/
|
*/
|
||||||
static void esci_init(SerialDriver *sdp, const SerialConfig *config) {
|
static void spc5_linflex_init(SerialDriver *sdp, const SerialConfig *config) {
|
||||||
volatile struct ESCI_tag *escip = sdp->escip;
|
volatile struct LINFLEX_tag *linflexp = sdp->linflexp;
|
||||||
uint8_t mode = config->sc_mode;
|
|
||||||
|
|
||||||
escip->CR2.R = 0; /* MDIS off. */
|
linflexp->LINFBRR.R = 0; /* Fractional divider. */
|
||||||
escip->CR1.R = 0;
|
linflexp->LINIBRR.R = 0; /* Integer divider. */
|
||||||
escip->LCR.R = 0;
|
linflexp->UARTSR.R = 0xFFFF; /* Clearing UART status register. */
|
||||||
escip->CR1.B.SBR = SPC563_SYSCLK / (16 * config->sc_speed);
|
linflexp->UARTCR.R = config->mode | 1;/* Enforced UART mode. */
|
||||||
if (mode & SD_MODE_LOOPBACK)
|
linflexp->LINIER.R = 0; /* Interrupts enabled. */
|
||||||
escip->CR1.B.LOOPS = 1;
|
|
||||||
switch (mode & SD_MODE_PARITY) {
|
|
||||||
case SD_MODE_PARITY_ODD:
|
|
||||||
escip->CR1.B.PT = 1;
|
|
||||||
case SD_MODE_PARITY_EVEN:
|
|
||||||
escip->CR1.B.PE = 1;
|
|
||||||
escip->CR1.B.M = 1; /* Makes it 8 bits data + 1 bit parity. */
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
escip->LPR.R = 0;
|
|
||||||
escip->CR1.R |= 0x0000002C; /* RIE, TE, RE to 1. */
|
|
||||||
escip->CR2.R |= 0x000F; /* ORIE, NFIE, FEIE, PFIE to 1. */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief eSCI de-initialization.
|
* @brief LINFlex de-initialization.
|
||||||
* @details This function must be invoked with interrupts disabled.
|
* @details This function must be invoked with interrupts disabled.
|
||||||
*
|
*
|
||||||
* @param[in] escip pointer to an eSCI I/O block
|
* @param[in] linflexp pointer to a LINFlex I/O block
|
||||||
*/
|
*/
|
||||||
static void esci_deinit(volatile struct ESCI_tag *escip) {
|
static void spc5_linflex_deinit(volatile struct LINFLEX_tag *linflexp) {
|
||||||
|
|
||||||
|
#if 0
|
||||||
escip->LPR.R = 0;
|
escip->LPR.R = 0;
|
||||||
escip->SR.R = 0xFFFFFFFF;
|
escip->SR.R = 0xFFFFFFFF;
|
||||||
escip->CR1.R = 0;
|
escip->CR1.R = 0;
|
||||||
escip->CR2.R = 0x8000; /* MDIS on. */
|
escip->CR2.R = 0x8000; /* MDIS on. */
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,6 +121,7 @@ static void esci_deinit(volatile struct ESCI_tag *escip) {
|
||||||
static void set_error(SerialDriver *sdp, uint32_t sr) {
|
static void set_error(SerialDriver *sdp, uint32_t sr) {
|
||||||
flagsmask_t sts = 0;
|
flagsmask_t sts = 0;
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (sr & 0x08000000)
|
if (sr & 0x08000000)
|
||||||
sts |= SD_OVERRUN_ERROR;
|
sts |= SD_OVERRUN_ERROR;
|
||||||
if (sr & 0x04000000)
|
if (sr & 0x04000000)
|
||||||
|
@ -129,71 +132,47 @@ static void set_error(SerialDriver *sdp, uint32_t sr) {
|
||||||
sts |= SD_PARITY_ERROR;
|
sts |= SD_PARITY_ERROR;
|
||||||
/* if (sr & 0x00000000)
|
/* if (sr & 0x00000000)
|
||||||
sts |= SD_BREAK_DETECTED;*/
|
sts |= SD_BREAK_DETECTED;*/
|
||||||
|
#endif
|
||||||
chSysLockFromIsr();
|
chSysLockFromIsr();
|
||||||
chnAddFlagsI(sdp, sts);
|
chnAddFlagsI(sdp, sts);
|
||||||
chSysUnlockFromIsr();
|
chSysUnlockFromIsr();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Common IRQ handler.
|
* @brief Common RXI IRQ handler.
|
||||||
*
|
*
|
||||||
* @param[in] sdp pointer to a @p SerialDriver object
|
* @param[in] sdp pointer to a @p SerialDriver object
|
||||||
*/
|
*/
|
||||||
static void serve_interrupt(SerialDriver *sdp) {
|
static void spc5xx_serve_rxi_interrupt(SerialDriver *sdp) {
|
||||||
volatile struct ESCI_tag *escip = sdp->escip;
|
|
||||||
|
|
||||||
uint32_t sr = escip->SR.R;
|
|
||||||
escip->SR.R = 0x3FFFFFFF; /* Does not clear TDRE | TC.*/
|
|
||||||
if (sr & 0x0F000000) /* OR | NF | FE | PF. */
|
|
||||||
set_error(sdp, sr);
|
|
||||||
if (sr & 0x20000000) { /* RDRF. */
|
|
||||||
chSysLockFromIsr();
|
|
||||||
sdIncomingDataI(sdp, escip->DR.B.D);
|
|
||||||
chSysUnlockFromIsr();
|
|
||||||
}
|
|
||||||
if (escip->CR1.B.TIE && (sr & 0x80000000)) { /* TDRE. */
|
|
||||||
msg_t b;
|
|
||||||
chSysLockFromIsr();
|
|
||||||
b = chOQGetI(&sdp->oqueue);
|
|
||||||
if (b < Q_OK) {
|
|
||||||
chnAddFlagsI(sdp, CHN_OUTPUT_EMPTY);
|
|
||||||
escip->CR1.B.TIE = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ESCI_A.SR.B.TDRE = 1;
|
|
||||||
escip->DR.R = (uint16_t)b;
|
|
||||||
}
|
|
||||||
chSysUnlockFromIsr();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USE_SPC563_ESCIA || defined(__DOXYGEN__)
|
/**
|
||||||
|
* @brief Common TXI IRQ handler.
|
||||||
|
*
|
||||||
|
* @param[in] sdp pointer to a @p SerialDriver object
|
||||||
|
*/
|
||||||
|
static void spc5xx_serve_txi_interrupt(SerialDriver *sdp) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Common ERR IRQ handler.
|
||||||
|
*
|
||||||
|
* @param[in] sdp pointer to a @p SerialDriver object
|
||||||
|
*/
|
||||||
|
static void spc5xx_serve_err_interrupt(SerialDriver *sdp) {
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SPC5_SERIAL_USE_LINFLEX0 || defined(__DOXYGEN__)
|
||||||
static void notify1(GenericQueue *qp) {
|
static void notify1(GenericQueue *qp) {
|
||||||
|
|
||||||
(void)qp;
|
(void)qp;
|
||||||
if (ESCI_A.SR.B.TDRE) {
|
|
||||||
msg_t b = sdRequestDataI(&SD1);
|
|
||||||
if (b != Q_EMPTY) {
|
|
||||||
ESCI_A.SR.B.TDRE = 1;
|
|
||||||
ESCI_A.CR1.B.TIE = 1;
|
|
||||||
ESCI_A.DR.R = (uint16_t)b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USE_SPC563_ESCIB || defined(__DOXYGEN__)
|
#if SPC5_SERIAL_USE_LINFLEX1 || defined(__DOXYGEN__)
|
||||||
static void notify2(GenericQueue *qp) {
|
static void notify2(GenericQueue *qp) {
|
||||||
|
|
||||||
(void)qp;
|
(void)qp;
|
||||||
if (ESCI_B.SR.B.TDRE) {
|
|
||||||
msg_t b = sdRequestDataI(&SD2);
|
|
||||||
if (b != Q_EMPTY) {
|
|
||||||
ESCI_B.SR.B.TDRE = 1;
|
|
||||||
ESCI_B.CR1.B.TIE = 1;
|
|
||||||
ESCI_B.DR.R = (uint16_t)b;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -201,33 +180,89 @@ static void notify2(GenericQueue *qp) {
|
||||||
/* Driver interrupt handlers. */
|
/* Driver interrupt handlers. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#if USE_SPC563_ESCIA || defined(__DOXYGEN__)
|
#if SPC5_SERIAL_USE_LINFLEX0 || defined(__DOXYGEN__)
|
||||||
/**
|
/**
|
||||||
* @brief eSCI-A interrupt handler.
|
* @brief LINFlex-0 RXI interrupt handler.
|
||||||
*
|
*
|
||||||
* @isr
|
* @isr
|
||||||
*/
|
*/
|
||||||
CH_IRQ_HANDLER(vector146) {
|
CH_IRQ_HANDLER(SPC5_LINFLEX0_RXI_HANDLER) {
|
||||||
|
|
||||||
CH_IRQ_PROLOGUE();
|
CH_IRQ_PROLOGUE();
|
||||||
|
|
||||||
serve_interrupt(&SD1);
|
spc5xx_serve_rxi_interrupt(&SD1);
|
||||||
|
|
||||||
|
CH_IRQ_EPILOGUE();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LINFlex-0 TXI interrupt handler.
|
||||||
|
*
|
||||||
|
* @isr
|
||||||
|
*/
|
||||||
|
CH_IRQ_HANDLER(SPC5_LINFLEX0_TXI_HANDLER) {
|
||||||
|
|
||||||
|
CH_IRQ_PROLOGUE();
|
||||||
|
|
||||||
|
spc5xx_serve_txi_interrupt(&SD1);
|
||||||
|
|
||||||
|
CH_IRQ_EPILOGUE();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LINFlex-0 ERR interrupt handler.
|
||||||
|
*
|
||||||
|
* @isr
|
||||||
|
*/
|
||||||
|
CH_IRQ_HANDLER(SPC5_LINFLEX0_ERR_HANDLER) {
|
||||||
|
|
||||||
|
CH_IRQ_PROLOGUE();
|
||||||
|
|
||||||
|
spc5xx_serve_err_interrupt(&SD1);
|
||||||
|
|
||||||
CH_IRQ_EPILOGUE();
|
CH_IRQ_EPILOGUE();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USE_SPC563_ESCIB || defined(__DOXYGEN__)
|
#if SPC5_SERIAL_USE_LINFLEX1 || defined(__DOXYGEN__)
|
||||||
/**
|
/**
|
||||||
* @brief eSCI-B interrupt handler.
|
* @brief LINFlex-1 RXI interrupt handler.
|
||||||
*
|
*
|
||||||
* @isr
|
* @isr
|
||||||
*/
|
*/
|
||||||
CH_IRQ_HANDLER(vector149) {
|
CH_IRQ_HANDLER(SPC5_LINFLEX1_RXI_HANDLER) {
|
||||||
|
|
||||||
CH_IRQ_PROLOGUE();
|
CH_IRQ_PROLOGUE();
|
||||||
|
|
||||||
serve_interrupt(&SD2);
|
spc5xx_serve_rxi_interrupt(&SD2);
|
||||||
|
|
||||||
|
CH_IRQ_EPILOGUE();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LINFlex-1 TXI interrupt handler.
|
||||||
|
*
|
||||||
|
* @isr
|
||||||
|
*/
|
||||||
|
CH_IRQ_HANDLER(SPC5_LINFLEX1_TXI_HANDLER) {
|
||||||
|
|
||||||
|
CH_IRQ_PROLOGUE();
|
||||||
|
|
||||||
|
spc5xx_serve_txi_interrupt(&SD2);
|
||||||
|
|
||||||
|
CH_IRQ_EPILOGUE();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief LINFlex-1 ERR interrupt handler.
|
||||||
|
*
|
||||||
|
* @isr
|
||||||
|
*/
|
||||||
|
CH_IRQ_HANDLER(SPC5_LINFLEX1_ERR_HANDLER) {
|
||||||
|
|
||||||
|
CH_IRQ_PROLOGUE();
|
||||||
|
|
||||||
|
spc5xx_serve_err_interrupt(&SD2);
|
||||||
|
|
||||||
CH_IRQ_EPILOGUE();
|
CH_IRQ_EPILOGUE();
|
||||||
}
|
}
|
||||||
|
@ -244,18 +279,22 @@ CH_IRQ_HANDLER(vector149) {
|
||||||
*/
|
*/
|
||||||
void sd_lld_init(void) {
|
void sd_lld_init(void) {
|
||||||
|
|
||||||
#if USE_SPC563_ESCIA
|
#if SPC5_SERIAL_USE_LINFLEX0
|
||||||
sdObjectInit(&SD1, NULL, notify1);
|
sdObjectInit(&SD1, NULL, notify1);
|
||||||
SD1.escip = &ESCI_A;
|
SD1.linflexp = &LINFLEX_0;
|
||||||
ESCI_A.CR2.R = 0x8000; /* MDIS ON. */
|
// ESCI_A.CR2.R = 0x8000; /* MDIS ON. */
|
||||||
INTC.PSR[146].R = SPC563_ESCIA_PRIORITY;
|
INTC.PSR[SPC5_LINFLEX0_RXI_NUMBER].R = SPC5_SERIAL_LINFLEX0_PRIORITY;
|
||||||
|
INTC.PSR[SPC5_LINFLEX0_TXI_NUMBER].R = SPC5_SERIAL_LINFLEX0_PRIORITY;
|
||||||
|
INTC.PSR[SPC5_LINFLEX0_ERR_NUMBER].R = SPC5_SERIAL_LINFLEX0_PRIORITY;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if USE_SPC563_ESCIB
|
#if SPC5_SERIAL_USE_LINFLEX1
|
||||||
sdObjectInit(&SD2, NULL, notify2);
|
sdObjectInit(&SD2, NULL, notify2);
|
||||||
SD2.escip = &ESCI_B;
|
SD2.linflexp = &LINFLEX_1;
|
||||||
ESCI_B.CR2.R = 0x8000; /* MDIS ON. */
|
// ESCI_B.CR2.R = 0x8000; /* MDIS ON. */
|
||||||
INTC.PSR[149].R = SPC563_ESCIB_PRIORITY;
|
INTC.PSR[SPC5_LINFLEX1_RXI_NUMBER].R = SPC5_SERIAL_LINFLEX1_PRIORITY;
|
||||||
|
INTC.PSR[SPC5_LINFLEX1_TXI_NUMBER].R = SPC5_SERIAL_LINFLEX1_PRIORITY;
|
||||||
|
INTC.PSR[SPC5_LINFLEX1_ERR_NUMBER].R = SPC5_SERIAL_LINFLEX1_PRIORITY;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +312,7 @@ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
|
||||||
|
|
||||||
if (config == NULL)
|
if (config == NULL)
|
||||||
config = &default_config;
|
config = &default_config;
|
||||||
esci_init(sdp, config);
|
spc5_linflex_init(sdp, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -286,7 +325,7 @@ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
|
||||||
void sd_lld_stop(SerialDriver *sdp) {
|
void sd_lld_stop(SerialDriver *sdp) {
|
||||||
|
|
||||||
if (sdp->state == SD_READY)
|
if (sdp->state == SD_READY)
|
||||||
esci_deinit(sdp->escip);
|
spc5_linflex_deinit(sdp->linflexp);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* HAL_USE_SERIAL */
|
#endif /* HAL_USE_SERIAL */
|
||||||
|
|
|
@ -40,41 +40,60 @@
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief eSCI-A driver enable switch.
|
* @brief LINFlex-0 driver enable switch.
|
||||||
* @details If set to @p TRUE the support for eSCI-A is included.
|
* @details If set to @p TRUE the support for LINFlex-0 is included.
|
||||||
* @note The default is @p TRUE.
|
|
||||||
*/
|
*/
|
||||||
#if !defined(USE_SPC563_ESCIA) || defined(__DOXYGEN__)
|
#if !defined(SPC5_SERIAL_USE_LINFLEX0) || defined(__DOXYGEN__)
|
||||||
#define USE_SPC563_ESCIA FALSE
|
#define SPC5_SERIAL_USE_LINFLEX0 TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief eSCI-B driver enable switch.
|
* @brief LINFlex-1 driver enable switch.
|
||||||
* @details If set to @p TRUE the support for eSCI-B is included.
|
* @details If set to @p TRUE the support for LINFlex-1 is included.
|
||||||
* @note The default is @p TRUE.
|
|
||||||
*/
|
*/
|
||||||
#if !defined(USE_SPC563_ESCIB) || defined(__DOXYGEN__)
|
#if !defined(SPC5_SERIAL_USE_LINFLEX1) || defined(__DOXYGEN__)
|
||||||
#define USE_SPC563_ESCIB FALSE
|
#define SPC5_SERIAL_USE_LINFLEX1 TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief eSCI-A interrupt priority level setting.
|
* @brief LINFlex-0 interrupt priority level setting.
|
||||||
*/
|
*/
|
||||||
#if !defined(SPC563_ESCIA_PRIORITY) || defined(__DOXYGEN__)
|
#if !defined(SPC5_SERIAL_LINFLEX0_PRIORITY) || defined(__DOXYGEN__)
|
||||||
#define SPC563_ESCIA_PRIORITY 8
|
#define SPC5_SERIAL_LINFLEX0_PRIORITY 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief eSCI-B interrupt priority level setting.
|
* @brief LINFlex-1 interrupt priority level setting.
|
||||||
*/
|
*/
|
||||||
#if !defined(SPC563_ESCIB_PRIORITY) || defined(__DOXYGEN__)
|
#if !defined(SPC5_SERIAL_LINFLEX1_PRIORITY) || defined(__DOXYGEN__)
|
||||||
#define SPC563_ESCIB_PRIORITY 8
|
#define SPC5_SERIAL_LINFLEX1_PRIORITY 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Derived constants and error checks. */
|
/* Derived constants and error checks. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#if SPC5_SERIAL_USE_LINFLEX0 && !SPC5_HAS_LINFLEX0
|
||||||
|
#error "LINFlex-0 not present in the selected device"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SPC5_SERIAL_USE_LINFLEX1 && !SPC5_HAS_LINFLEX1
|
||||||
|
#error "LINFlex-1 not present in the selected device"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SPC5_SERIAL_USE_LINFLEX2 && !SPC5_HAS_LINFLEX2
|
||||||
|
#error "LINFlex-2 not present in the selected device"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SPC5_SERIAL_USE_LINFLEX3 && !SPC5_HAS_LINFLEX3
|
||||||
|
#error "LINFlex-3 not present in the selected device"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !SPC5_SERIAL_USE_LINFLEX0 && !SPC5_SERIAL_USE_LINFLEX1 && \
|
||||||
|
!SPC5_SERIAL_USE_LINFLEX2 && !SPC5_SERIAL_USE_LINFLEX3
|
||||||
|
#error "SERIAL driver activated but no LINFlex peripheral assigned"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver data structures and types. */
|
/* Driver data structures and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -91,11 +110,11 @@ typedef struct {
|
||||||
/**
|
/**
|
||||||
* @brief Bit rate.
|
* @brief Bit rate.
|
||||||
*/
|
*/
|
||||||
uint32_t sc_speed;
|
uint32_t speed;
|
||||||
/**
|
/**
|
||||||
* @brief Mode flags.
|
* @brief Mode flags.
|
||||||
*/
|
*/
|
||||||
uint8_t sc_mode;
|
uint8_t mode;
|
||||||
} SerialConfig;
|
} SerialConfig;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,8 +133,8 @@ typedef struct {
|
||||||
/* Output circular buffer.*/ \
|
/* Output circular buffer.*/ \
|
||||||
uint8_t ob[SERIAL_BUFFERS_SIZE]; \
|
uint8_t ob[SERIAL_BUFFERS_SIZE]; \
|
||||||
/* End of the mandatory fields.*/ \
|
/* End of the mandatory fields.*/ \
|
||||||
/* Pointer to the volatile eSCI registers block.*/ \
|
/* Pointer to the volatile LINFlex registers block.*/ \
|
||||||
volatile struct ESCI_tag *escip;
|
volatile struct LINFLEX_tag *linflexp;
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver macros. */
|
/* Driver macros. */
|
||||||
|
@ -125,12 +144,18 @@ typedef struct {
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#if USE_SPC563_ESCIA && !defined(__DOXYGEN__)
|
#if SPC5_SERIAL_USE_LINFLEX0 && !defined(__DOXYGEN__)
|
||||||
extern SerialDriver SD1;
|
extern SerialDriver SD1;
|
||||||
#endif
|
#endif
|
||||||
#if USE_SPC563_ESCIB && !defined(__DOXYGEN__)
|
#if SPC5_SERIAL_USE_LINFLEX1 && !defined(__DOXYGEN__)
|
||||||
extern SerialDriver SD2;
|
extern SerialDriver SD2;
|
||||||
#endif
|
#endif
|
||||||
|
#if SPC5_SERIAL_USE_LINFLEX2 && !defined(__DOXYGEN__)
|
||||||
|
extern SerialDriver SD3;
|
||||||
|
#endif
|
||||||
|
#if SPC5_SERIAL_USE_LINFLEX3 && !defined(__DOXYGEN__)
|
||||||
|
extern SerialDriver SD4;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
#undef PAL_MODE_OUTPUT_OPENDRAIN
|
#undef PAL_MODE_OUTPUT_OPENDRAIN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name SIUL-specific PAL modes
|
* @name SIU/SIUL-specific PAL modes
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define PAL_SPC5_SMC (1U << 14)
|
#define PAL_SPC5_SMC (1U << 14)
|
||||||
|
@ -141,7 +141,7 @@ typedef uint16_t iomode_t;
|
||||||
typedef uint32_t ioportid_t;
|
typedef uint32_t ioportid_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SIUL register initializer type.
|
* @brief SIU/SIUL register initializer type.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t pcr_index;
|
uint8_t pcr_index;
|
||||||
|
|
Loading…
Reference in New Issue