nrf5/spi: Removing automatic chip select (NSS) in hal_spi.c. Also removing configuration of this pin as it is confusing to pass it if not used. User of SPI has to set the NSS/CS itself.
This commit is contained in:
parent
bcb0c9d8cb
commit
04751defa0
|
@ -32,8 +32,6 @@
|
|||
|
||||
#ifdef HAL_SPI_MODULE_ENABLED
|
||||
|
||||
static uint32_t m_ss_pin;
|
||||
|
||||
static const uint32_t hal_spi_frequency_lookup[] = {
|
||||
SPI_FREQUENCY_FREQUENCY_K125, // 125 kbps
|
||||
SPI_FREQUENCY_FREQUENCY_K250, // 250 kbps
|
||||
|
@ -45,13 +43,9 @@ static const uint32_t hal_spi_frequency_lookup[] = {
|
|||
};
|
||||
|
||||
void hal_spi_master_init(NRF_SPI_Type * p_instance, hal_spi_init_t const * p_spi_init) {
|
||||
hal_gpio_pin_set(p_spi_init->enable_pin);
|
||||
m_ss_pin = p_spi_init->enable_pin;
|
||||
|
||||
hal_gpio_cfg_pin(p_spi_init->clk_pin, HAL_GPIO_MODE_OUTPUT, HAL_GPIO_PULL_DISABLED);
|
||||
hal_gpio_cfg_pin(p_spi_init->mosi_pin, HAL_GPIO_MODE_OUTPUT, HAL_GPIO_PULL_DISABLED);
|
||||
hal_gpio_cfg_pin(p_spi_init->miso_pin, HAL_GPIO_MODE_INPUT, HAL_GPIO_PULL_DISABLED);
|
||||
hal_gpio_cfg_pin(p_spi_init->enable_pin, HAL_GPIO_MODE_OUTPUT, HAL_GPIO_PULL_DISABLED);
|
||||
|
||||
#if NRF51
|
||||
p_instance->PSELSCK = p_spi_init->clk_pin;
|
||||
|
@ -100,8 +94,6 @@ void hal_spi_master_tx_rx(NRF_SPI_Type * p_instance, uint16_t transfer_size, con
|
|||
|
||||
p_instance->EVENTS_READY = 0;
|
||||
|
||||
hal_gpio_pin_clear(m_ss_pin);
|
||||
|
||||
while (number_of_txd_bytes < transfer_size) {
|
||||
p_instance->TXD = (uint32_t)(tx_data[number_of_txd_bytes]);
|
||||
|
||||
|
@ -114,9 +106,6 @@ void hal_spi_master_tx_rx(NRF_SPI_Type * p_instance, uint16_t transfer_size, con
|
|||
rx_data[number_of_txd_bytes] = (uint8_t)p_instance->RXD;
|
||||
number_of_txd_bytes++;
|
||||
};
|
||||
|
||||
hal_gpio_pin_set(m_ss_pin);
|
||||
|
||||
}
|
||||
|
||||
#endif // HAL_SPI_MODULE_ENABLED
|
||||
|
|
|
@ -79,7 +79,6 @@ typedef struct {
|
|||
uint8_t mosi_pin;
|
||||
uint8_t miso_pin;
|
||||
uint8_t clk_pin;
|
||||
uint8_t enable_pin;
|
||||
bool lsb_first;
|
||||
hal_spi_mode_t mode;
|
||||
uint32_t irq_priority;
|
||||
|
|
|
@ -263,12 +263,10 @@ STATIC mp_obj_t machine_hard_spi_make_new(mp_arg_val_t *args) {
|
|||
spi_init_conf.clk_pin = mp_obj_get_int(args[ARG_NEW_sck].u_obj);
|
||||
spi_init_conf.mosi_pin = mp_obj_get_int(args[ARG_NEW_mosi].u_obj);
|
||||
spi_init_conf.miso_pin = mp_obj_get_int(args[ARG_NEW_miso].u_obj);
|
||||
spi_init_conf.enable_pin = MICROPY_HW_SPI0_NSS;
|
||||
} else {
|
||||
spi_init_conf.clk_pin = MICROPY_HW_SPI0_SCK;
|
||||
spi_init_conf.mosi_pin = MICROPY_HW_SPI0_MOSI;
|
||||
spi_init_conf.miso_pin = MICROPY_HW_SPI0_MISO;
|
||||
spi_init_conf.enable_pin = MICROPY_HW_SPI0_NSS;
|
||||
}
|
||||
|
||||
int baudrate = args[ARG_NEW_baudrate].u_int;
|
||||
|
|
Loading…
Reference in New Issue