Add smartcard interface support for ST Nucleo Board.
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,13 @@
|
|||||||
|
2019-02-28 NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
|
* contrib/usart.h (BSCARD): New.
|
||||||
|
* contrib/usart-stm32f103.c (BSCARD): Baudrate for smartcard.
|
||||||
|
(usart_config_clken): New.
|
||||||
|
(usart_config): Fix for MODE_SMARTCARD.
|
||||||
|
|
||||||
|
* board/board-st-nucleo-f103.h: Define pins for smartcard
|
||||||
|
interface.
|
||||||
|
|
||||||
2019-02-21 NIIBE Yutaka <gniibe@fsij.org>
|
2019-02-21 NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
* contrib/usart.h (MODE_SMARTCARD, MODE_IRDA, MODE_IRDA_LP)
|
* contrib/usart.h (MODE_SMARTCARD, MODE_IRDA, MODE_IRDA_LP)
|
||||||
|
|||||||
@@ -49,17 +49,26 @@
|
|||||||
* Port B setup.
|
* Port B setup.
|
||||||
* PB0 - input with pull-up: AN8 for NeuG
|
* PB0 - input with pull-up: AN8 for NeuG
|
||||||
* PB1 - input with pull-up: AN9 for NeuG
|
* PB1 - input with pull-up: AN9 for NeuG
|
||||||
* PB10 - Alternate function push pull output 2MHz USART3-TX
|
* ---
|
||||||
* PB11 - Input with pull-up USART3-RX
|
* ---
|
||||||
* PB12 - Alternate function push pull output 2MHz USART3-CK
|
* PB4 - Input with pull-up: Card insertion detect: 0 when detected
|
||||||
* PB13 - Input with pull-up USART3-CTS
|
* ---
|
||||||
* PB14 - Alternate function push pull output 2MHz USART3-RTS
|
* PB6 - Output push pull 2MHz: Vcc for card: default 0
|
||||||
|
* ---
|
||||||
|
* PB8 - Output push pull 2MHz: Vpp for card: default 0
|
||||||
|
* PB9 - Output push pull 2MHz: RST for card: default 0
|
||||||
|
* PB10 - Alternate function open-drain output 50MHz USART3-TX
|
||||||
|
* PB11 - Input with pull-up USART3-RX
|
||||||
|
* PB12 - Alternate function push pull output 50MHz USART3-CK
|
||||||
|
* PB13 - Input with pull-up USART3-CTS
|
||||||
|
* PB14 - Alternate function push pull output 50MHz USART3-RTS
|
||||||
|
* ---
|
||||||
* ------------------------ Default
|
* ------------------------ Default
|
||||||
* PBx - input with pull-up.
|
* PBx - input with pull-up.
|
||||||
*/
|
*/
|
||||||
#define VAL_GPIO_OTHER_ODR 0xFFFFFFFF
|
#define VAL_GPIO_OTHER_ODR 0xFFFFFCBF
|
||||||
#define VAL_GPIO_OTHER_CRL 0x88888888 /* PB7...PB0 */
|
#define VAL_GPIO_OTHER_CRL 0x82888888 /* PB7...PB0 */
|
||||||
#define VAL_GPIO_OTHER_CRH 0x8A8A8A88 /* PB15...PB8 */
|
#define VAL_GPIO_OTHER_CRH 0x8B8B8F22 /* PB15...PB8 */
|
||||||
|
|
||||||
#define RCC_ENR_IOP_EN (RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPBEN)
|
#define RCC_ENR_IOP_EN (RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPBEN)
|
||||||
#define RCC_RSTR_IOP_RST (RCC_APB2RSTR_IOPARST | RCC_APB2RSTR_IOPBRST)
|
#define RCC_RSTR_IOP_RST (RCC_APB2RSTR_IOPARST | RCC_APB2RSTR_IOPBRST)
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ static const struct brr_setting brr_table[] = {
|
|||||||
{ B230400, ( 9 << 4)|12},
|
{ B230400, ( 9 << 4)|12},
|
||||||
{ B460800, ( 4 << 4)|14},
|
{ B460800, ( 4 << 4)|14},
|
||||||
{ B921600, ( 2 << 4)|7},
|
{ B921600, ( 2 << 4)|7},
|
||||||
|
{ BSCARD, ( 232 << 4)|8},
|
||||||
};
|
};
|
||||||
|
|
||||||
static void *usart_main (void *arg);
|
static void *usart_main (void *arg);
|
||||||
@@ -111,6 +112,18 @@ static void *usart_main (void *arg);
|
|||||||
static struct usart_stat usart2_stat;
|
static struct usart_stat usart2_stat;
|
||||||
static struct usart_stat usart3_stat;
|
static struct usart_stat usart3_stat;
|
||||||
|
|
||||||
|
void
|
||||||
|
usart_config_clken (uint8_t dev_no, int on)
|
||||||
|
{
|
||||||
|
struct USART *USARTx = get_usart_dev (dev_no);
|
||||||
|
|
||||||
|
if (on)
|
||||||
|
USARTx->CR2 |= (1 << 11);
|
||||||
|
else
|
||||||
|
USARTx->CR2 &= ~(1 << 11);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
usart_config (uint8_t dev_no, uint32_t config_bits)
|
usart_config (uint8_t dev_no, uint32_t config_bits)
|
||||||
{
|
{
|
||||||
@@ -172,8 +185,8 @@ usart_config (uint8_t dev_no, uint32_t config_bits)
|
|||||||
{
|
{
|
||||||
if ((config_bits & MASK_MODE) == MODE_SMARTCARD)
|
if ((config_bits & MASK_MODE) == MODE_SMARTCARD)
|
||||||
{
|
{
|
||||||
USARTx->CR2 |= (0x1 << 11);
|
USARTx->GTPR = (16 << 8) | 5;
|
||||||
USARTx->CR3 |= (1 << 5);
|
USARTx->CR3 |= ((1 << 5) | (1 << 4));
|
||||||
}
|
}
|
||||||
else if ((config_bits & MASK_MODE) == MODE_IRDA)
|
else if ((config_bits & MASK_MODE) == MODE_IRDA)
|
||||||
USARTx->CR3 |= (1 << 1);
|
USARTx->CR3 |= (1 << 1);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#define B230400 26
|
#define B230400 26
|
||||||
#define B460800 27
|
#define B460800 27
|
||||||
#define B921600 28
|
#define B921600 28
|
||||||
|
#define BSCARD 63
|
||||||
#define MASK_BAUD 0x3f
|
#define MASK_BAUD 0x3f
|
||||||
|
|
||||||
/* POSIX supports 5, 6. USB suppots 16 */
|
/* POSIX supports 5, 6. USB suppots 16 */
|
||||||
@@ -71,3 +72,4 @@ int usart_read (uint8_t dev_no, char *buf, uint16_t buflen);
|
|||||||
int usart_write (uint8_t dev_no, char *buf, uint16_t buflen);
|
int usart_write (uint8_t dev_no, char *buf, uint16_t buflen);
|
||||||
const struct usart_stat *usart_stat (uint8_t dev_no);
|
const struct usart_stat *usart_stat (uint8_t dev_no);
|
||||||
int usart_send_break (uint8_t dev_no);
|
int usart_send_break (uint8_t dev_no);
|
||||||
|
void usart_config_clken (uint8_t dev_no, int on);
|
||||||
|
|||||||
Reference in New Issue
Block a user