Permalink
Browse files

Change pin names (CMD->VCC and OFF->CD)

  • Loading branch information...
Baldanos committed Nov 22, 2018
1 parent ab5f9ed commit e93be6ced16bcbc0faacd2ac24fa5fa1bedf6d0e
@@ -66,23 +66,23 @@ static void smartcard_gpio_hw_init(bsp_dev_smartcard_t dev_num)
GPIO_InitStructure.Mode = GPIO_MODE_AF_OD;
HAL_GPIO_Init(BSP_SMARTCARD1_TX_PORT, &GPIO_InitStructure);
/*SMARTCARD1 CMD pin configuration*/
GPIO_InitStructure.Pin = BSP_SMARTCARD1_CMD_PIN;
/*SMARTCARD1 VCC pin configuration*/
GPIO_InitStructure.Pin = BSP_SMARTCARD1_VCC_PIN;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStructure.Pull = GPIO_NOPULL;
GPIO_InitStructure.Speed = BSP_SMARTCARD1_GPIO_SPEED;
HAL_GPIO_Init(BSP_SMARTCARD1_CMD_PORT, &GPIO_InitStructure);
HAL_GPIO_Init(BSP_SMARTCARD1_VCC_PORT, &GPIO_InitStructure);
/*SMARTCARD1 RST pin configuration*/
GPIO_InitStructure.Pin = BSP_SMARTCARD1_RST_PIN;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(BSP_SMARTCARD1_RST_PORT, &GPIO_InitStructure);
/*SMARTCARD1 OFF pin configuration*/
GPIO_InitStructure.Pin = BSP_SMARTCARD1_OFF_PIN;
/*SMARTCARD1 CD pin configuration*/
GPIO_InitStructure.Pin = BSP_SMARTCARD1_CD_PIN;
GPIO_InitStructure.Mode = GPIO_MODE_INPUT;
GPIO_InitStructure.Pull = GPIO_NOPULL;
HAL_GPIO_Init(BSP_SMARTCARD1_OFF_PORT, &GPIO_InitStructure);
HAL_GPIO_Init(BSP_SMARTCARD1_CD_PORT, &GPIO_InitStructure);
}
/**
@@ -102,9 +102,9 @@ static void smartcard_gpio_hw_deinit(bsp_dev_smartcard_t dev_num)
__USART1_RELEASE_RESET();
/* Disable peripherals GPIO */
HAL_GPIO_DeInit(BSP_SMARTCARD1_CMD_PORT, BSP_SMARTCARD1_CMD_PIN);
HAL_GPIO_DeInit(BSP_SMARTCARD1_VCC_PORT, BSP_SMARTCARD1_VCC_PIN);
HAL_GPIO_DeInit(BSP_SMARTCARD1_RST_PORT, BSP_SMARTCARD1_RST_PIN);
HAL_GPIO_DeInit(BSP_SMARTCARD1_OFF_PORT, BSP_SMARTCARD1_OFF_PIN);
HAL_GPIO_DeInit(BSP_SMARTCARD1_CD_PORT, BSP_SMARTCARD1_CD_PIN);
HAL_GPIO_DeInit(BSP_SMARTCARD1_CLK_PORT, BSP_SMARTCARD1_CLK_PIN);
HAL_GPIO_DeInit(BSP_SMARTCARD1_TX_PORT, BSP_SMARTCARD1_TX_PIN);
@@ -347,40 +347,40 @@ void bsp_smartcard_set_rst(bsp_dev_smartcard_t dev_num, uint8_t state)
HAL_GPIO_WritePin(BSP_SMARTCARD1_RST_PORT, BSP_SMARTCARD1_RST_PIN, state);
}
/** @brief Get Smartcard Reader CMD pin
/** @brief Get Smartcard Reader VCC pin
* @param dev_num: smartcard device
* @retval state: CMD pin value
* @retval state: VCC pin value
*
*/
uint8_t bsp_smartcard_get_cmd(bsp_dev_smartcard_t dev_num)
uint8_t bsp_smartcard_get_vcc(bsp_dev_smartcard_t dev_num)
{
(void)dev_num;
return HAL_GPIO_ReadPin(BSP_SMARTCARD1_CMD_PORT,BSP_SMARTCARD1_CMD_PIN);
return HAL_GPIO_ReadPin(BSP_SMARTCARD1_VCC_PORT,BSP_SMARTCARD1_VCC_PIN);
}
/** @brief Set Smartcard Reader CMD pin
/** @brief Set Smartcard Reader VCC pin
* @param dev_num: Smartcard device
* @param state: desired state
*
*/
void bsp_smartcard_set_cmd(bsp_dev_smartcard_t dev_num, uint8_t state)
void bsp_smartcard_set_vcc(bsp_dev_smartcard_t dev_num, uint8_t state)
{
(void)dev_num;
HAL_GPIO_WritePin(BSP_SMARTCARD1_CMD_PORT,BSP_SMARTCARD1_CMD_PIN, state);
HAL_GPIO_WritePin(BSP_SMARTCARD1_VCC_PORT,BSP_SMARTCARD1_VCC_PIN, state);
}
/** @brief Detects whether the Smartcard is present or not.
* @param dev_num: smartcard device
* @retval state: OFF pin value
* @retval state: CD pin value
*
*/
uint8_t bsp_smartcard_get_off(bsp_dev_smartcard_t dev_num)
uint8_t bsp_smartcard_get_cd(bsp_dev_smartcard_t dev_num)
{
(void)dev_num;
return HAL_GPIO_ReadPin(BSP_SMARTCARD1_OFF_PORT,BSP_SMARTCARD1_OFF_PIN);
return HAL_GPIO_ReadPin(BSP_SMARTCARD1_CD_PORT,BSP_SMARTCARD1_CD_PIN);
}
/**
@@ -36,13 +36,13 @@ bsp_status_t bsp_smartcard_rxne(bsp_dev_smartcard_t dev_num);
uint32_t bsp_smartcard_get_final_baudrate(bsp_dev_smartcard_t dev_num);
uint8_t bsp_smartcard_get_off(bsp_dev_smartcard_t dev_num);
uint8_t bsp_smartcard_get_cd(bsp_dev_smartcard_t dev_num);
uint8_t bsp_smartcard_get_rst(bsp_dev_smartcard_t dev_num);
void bsp_smartcard_set_rst(bsp_dev_smartcard_t dev_num, uint8_t state);
uint8_t bsp_smartcard_get_cmd(bsp_dev_smartcard_t dev_num);
void bsp_smartcard_set_cmd(bsp_dev_smartcard_t dev_num, uint8_t state);
uint8_t bsp_smartcard_get_vcc(bsp_dev_smartcard_t dev_num);
void bsp_smartcard_set_vcc(bsp_dev_smartcard_t dev_num, uint8_t state);
float bsp_smartcard_get_clk_frequency(bsp_dev_smartcard_t dev_num);
@@ -21,17 +21,17 @@ limitations under the License.
#define BSP_SMARTCARD1_GPIO_SPEED GPIO_SPEED_FAST
#define BSP_SMARTCARD1_AF GPIO_AF7_USART1
/* SMARTCARD1 CMD */
#define BSP_SMARTCARD1_CMD_PORT GPIOA
#define BSP_SMARTCARD1_CMD_PIN GPIO_PIN_5 /* PA.05 */
/* SMARTCARD1 VCC */
#define BSP_SMARTCARD1_VCC_PORT GPIOA
#define BSP_SMARTCARD1_VCC_PIN GPIO_PIN_5 /* PA.05 */
/* SMARTCARD1 RST */
#define BSP_SMARTCARD1_RST_PORT GPIOA
#define BSP_SMARTCARD1_RST_PIN GPIO_PIN_6 /* PA.06 */
/* SMARTCARD1 OFF */
#define BSP_SMARTCARD1_OFF_PORT GPIOA
#define BSP_SMARTCARD1_OFF_PIN GPIO_PIN_7 /* PA.07 */
/* SMARTCARD1 CD */
#define BSP_SMARTCARD1_CD_PORT GPIOA
#define BSP_SMARTCARD1_CD_PIN GPIO_PIN_7 /* PA.07 */
/* SMARTCARD1 CLK */
#define BSP_SMARTCARD1_CLK_PORT GPIOA
@@ -28,7 +28,7 @@ static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos);
static int show(t_hydra_console *con, t_tokenline_parsed *p);
static const char* str_pins_smartcard[] = {
"CMD: PA5\r\nRST: PA6\r\nOFF: PA7\r\nCLK: PA8\r\nTX : PB6\r\n"
"/VCC: PA5\r\nRST: PA6\r\nCD: PA7\r\nCLK: PA8\r\nTX : PB6\r\n"
};
static const char* str_prompt_smartcard[] = {
"smartcard1" PROMPT,
@@ -107,9 +107,9 @@ static void smartcard_get_card_status(t_hydra_console *con)
{
mode_config_proto_t* proto = &con->mode->proto;
uint8_t off_value;
off_value = bsp_smartcard_get_off(proto->dev_num);
cprintf(con, "OFF=%d\r\n", off_value);
uint8_t cd_value;
cd_value = bsp_smartcard_get_cd(proto->dev_num);
cprintf(con, "CD=%d\r\n", cd_value);
}
static void smartcard_get_atr(t_hydra_console *con)
@@ -134,7 +134,7 @@ static void smartcard_get_atr(t_hydra_console *con)
bsp_smartcard_set_rst(proto->dev_num, 0); // Start with RST low.
DelayMs(1); // RST low for at least 400 clocks.
bsp_smartcard_read_u8_timeout(proto->dev_num, atr, 1, 1); // Empty read buffer.
bsp_smartcard_set_cmd(proto->dev_num, 0);
bsp_smartcard_set_vcc(proto->dev_num, 0);
bsp_smartcard_set_rst(proto->dev_num, 1);
bsp_smartcard_read_u8(proto->dev_num, atr, 1);
@@ -159,7 +159,7 @@ static void smartcard_get_atr(t_hydra_console *con)
atr_size = bsp_smartcard_read_u8_timeout(proto->dev_num, &atr[1], 8, MS2ST(100));
print_hex(con, atr, atr_size);
bsp_smartcard_set_rst(proto->dev_num, 0);
bsp_smartcard_set_cmd(proto->dev_num, 1);
bsp_smartcard_set_vcc(proto->dev_num, 1);
return;
}
@@ -219,7 +219,7 @@ static void smartcard_get_atr(t_hydra_console *con)
}
bsp_smartcard_set_rst(proto->dev_num, 0);
bsp_smartcard_set_cmd(proto->dev_num, 1);
bsp_smartcard_set_vcc(proto->dev_num, 1);
}
static void smartcard_rst_high(t_hydra_console *con)
@@ -238,20 +238,20 @@ static void smartcard_rst_low(t_hydra_console *con)
bsp_smartcard_set_rst(proto->dev_num, 0);
}
static void smartcard_cmd_high(t_hydra_console *con)
static void smartcard_vcc_high(t_hydra_console *con)
{
mode_config_proto_t* proto = &con->mode->proto;
cprintf(con, "CMD UP\r\n");
bsp_smartcard_set_cmd(proto->dev_num, 1);
cprintf(con, "/VCC UP\r\n");
bsp_smartcard_set_vcc(proto->dev_num, 1);
}
static void smartcard_cmd_low(t_hydra_console *con)
static void smartcard_vcc_low(t_hydra_console *con)
{
mode_config_proto_t* proto = &con->mode->proto;
cprintf(con, "CMD DOWN\r\n");
bsp_smartcard_set_cmd(proto->dev_num, 0);
cprintf(con, "/VCC DOWN\r\n");
bsp_smartcard_set_vcc(proto->dev_num, 0);
}
static int exec(t_hydra_console *con, t_tokenline_parsed *p, int token_pos)
@@ -537,8 +537,8 @@ const mode_exec_t mode_smartcard_exec = {
.write_read = &write_read,
.cleanup = &cleanup,
.get_prompt = &get_prompt,
.dath = &smartcard_cmd_high,
.datl = &smartcard_cmd_low,
.dath = &smartcard_vcc_high,
.datl = &smartcard_vcc_low,
.start = &smartcard_rst_high,
.stop = &smartcard_rst_low,
};
@@ -23,8 +23,8 @@
static void smartcard_rst_high(t_hydra_console *con);
static void smartcard_rst_low(t_hydra_console *con);
static void smartcard_cmd_high(t_hydra_console *con);
static void smartcard_cmd_low(t_hydra_console *con);
static void smartcard_vcc_high(t_hydra_console *con);
static void smartcard_vcc_low(t_hydra_console *con);
static uint32_t read(t_hydra_console *con, uint8_t *rx_data, uint8_t nb_data);
static uint32_t write(t_hydra_console *con, uint8_t *rx_data, uint8_t nb_data);

0 comments on commit e93be6c

Please sign in to comment.