This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Keyboard gpio init code , pins set as output but pull up/down resistor disable.

Hi, I am confused by this config. 

static void drv_keyboard_gpio_init(void)
{
// Make sure that columns will drive 0 when they will be configured as outputs.
NRF_GPIO->OUTCLR = KEYBOARD_MASK_COL_ALL;

// Configure Columns.
drv_keyboard_gpio_cfg(KEYBOARD_MASK_COL_ALL,
(GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) |
(GPIO_PIN_CNF_DRIVE_D0S1 << GPIO_PIN_CNF_DRIVE_Pos) |
(GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) |
(GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos) |
(GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) );

// Configure Rows.
drv_keyboard_gpio_cfg(KEYBOARD_MASK_ROW_ALL,
(GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos) |
(GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) |
(GPIO_PIN_CNF_PULL_Pulldown << GPIO_PIN_CNF_PULL_Pos) |
(GPIO_PIN_CNF_DIR_Input << GPIO_PIN_CNF_DIR_Pos) |
(GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) );
}

In key sacn  function:

for (column = 0; column < KEYBOARD_NUM_OF_COLUMNS; column++)
{
uint8_t pin = m_column_to_pin_map[column];
uint32_t gpio_state;

if (!IS_IO_VALID(pin))
{
rows_state[column] = 0;
continue;
}

// Drive "1" on the selected column.
NRF_GPIO->OUTSET = (1ul << pin);
__DSB();

// Wait for column signal propagation.
nrf_delay_us(KEYBOARD_SELECT_TIME);

// Read GPIOs state.
gpio_state = NRF_GPIO->IN;

// Restore "0" on the selected column.
NRF_GPIO->OUTCLR = (1ul << pin);
__DSB();

// Save rows state for given column.
rows_state[column] = drv_keyboard_get_rows_state(gpio_state);
}

I guess nRF52832 output is open drain? 

In Columns configuration part, pull up/down resistor is disabled.  How to drive 1 when the output pin disables pull up resistor?

Thanks.

Related