mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-02 02:41:28 +00:00
embed: introduce {sdcard,touch}_active_pin_state
This commit is contained in:
parent
c97226a4c9
commit
ca9162f7b7
@ -51,7 +51,7 @@
|
||||
|
||||
static SD_HandleTypeDef sd_handle;
|
||||
|
||||
static void sdcard_default_pin_state(void) {
|
||||
static inline void sdcard_default_pin_state(void) {
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_SET); // SD_ON/PC0
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_RESET); // SD_DAT0/PC8
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_9, GPIO_PIN_RESET); // SD_DAT1/PC9
|
||||
@ -59,17 +59,28 @@ static void sdcard_default_pin_state(void) {
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_11, GPIO_PIN_RESET); // SD_DAT3/PC11
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_12, GPIO_PIN_RESET); // SD_CLK/PC12
|
||||
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_2, GPIO_PIN_RESET); // SD_CMD/PD2
|
||||
|
||||
// set above pins to OUTPUT / NOPULL
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStructure.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_0 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_2;
|
||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
void sdcard_init(void) {
|
||||
sdcard_default_pin_state();
|
||||
static inline void sdcard_active_pin_state(void) {
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_RESET); // SD_ON/PC0
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
// configure the SD card circuitry on/off pin
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStructure.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_0;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
|
||||
@ -91,6 +102,11 @@ void sdcard_init(void) {
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
|
||||
void sdcard_init(void) {
|
||||
sdcard_default_pin_state();
|
||||
}
|
||||
|
||||
void HAL_SD_MspInit(SD_HandleTypeDef *hsd) {
|
||||
// enable SDIO clock
|
||||
__HAL_RCC_SDIO_CLK_ENABLE();
|
||||
@ -109,7 +125,7 @@ secbool sdcard_power_on(void) {
|
||||
return sectrue;
|
||||
}
|
||||
// turn on SD card circuitry
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_RESET); // SD_ON/PC0
|
||||
sdcard_active_pin_state();
|
||||
HAL_Delay(50);
|
||||
|
||||
// SD device interface configuration
|
||||
|
@ -39,24 +39,35 @@
|
||||
|
||||
static I2C_HandleTypeDef i2c_handle;
|
||||
|
||||
static void touch_default_pin_state(void) {
|
||||
static inline void touch_default_pin_state(void) {
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_SET); // CTP_ON/PB10
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET); // CTP_I2C_SCL/PB6
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET); // CTP_I2C_SDA/PB7
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_5, GPIO_PIN_SET); // CTPM_REST/PC5
|
||||
// don't touch CTPM_INT = leave in High Z
|
||||
|
||||
// set above pins to OUTPUT / NOPULL
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStructure.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_10 | GPIO_PIN_6 | GPIO_PIN_7;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_5;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||
}
|
||||
|
||||
void touch_init(void)
|
||||
{
|
||||
touch_default_pin_state();
|
||||
static inline void touch_active_pin_state(void) {
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET); // CTP_ON/PB10
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_5, GPIO_PIN_SET); // CTPM_REST/PC5
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
|
||||
// configure the CTP circuitry on/off pin
|
||||
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStructure.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
GPIO_InitStructure.Pin = GPIO_PIN_10;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
@ -87,6 +98,10 @@ void touch_init(void)
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStructure); // switch the pin to be an output
|
||||
}
|
||||
|
||||
void touch_init(void) {
|
||||
touch_default_pin_state();
|
||||
}
|
||||
|
||||
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c) {
|
||||
// enable I2C clock
|
||||
__HAL_RCC_I2C1_CLK_ENABLE();
|
||||
@ -103,7 +118,7 @@ void touch_power_on(void) {
|
||||
}
|
||||
|
||||
// turn on CTP circuitry
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET); // CTP_ON/PB10
|
||||
touch_active_pin_state();
|
||||
HAL_Delay(50);
|
||||
|
||||
// I2C device interface configuration
|
||||
|
Loading…
Reference in New Issue
Block a user