mirror of https://github.com/ARMmbed/mbed-os.git
MCUXpresso: Update LPC SPI HAL driver
Add support for different slave selects Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>pull/11060/head
parent
9cdfe37783
commit
55a2eddf8a
|
@ -58,6 +58,7 @@ struct i2c_s {
|
|||
struct spi_s {
|
||||
uint32_t instance;
|
||||
uint8_t bits;
|
||||
uint8_t ssel_num;
|
||||
};
|
||||
|
||||
#if DEVICE_FLASH && !defined(TARGET_FLASH_CMSIS_ALGO)
|
||||
|
|
|
@ -33,7 +33,7 @@ void pin_function(PinName pin, int function)
|
|||
IOCON->PIO[port_number][pin_number] |= IOCON_PIO_DIGIMODE_MASK;
|
||||
|
||||
reg = IOCON->PIO[port_number][pin_number];
|
||||
reg = (reg & ~0x7) | (function & IOCON_PIO_FUNC_MASK);
|
||||
reg = (reg & ~IOCON_PIO_FUNC_MASK) | (function & IOCON_PIO_FUNC_MASK);
|
||||
IOCON->PIO[port_number][pin_number] = reg;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
|
||||
obj->instance = pinmap_merge(spi_data, spi_cntl);
|
||||
MBED_ASSERT((int)obj->instance != NC);
|
||||
obj->ssel_num = 0;
|
||||
|
||||
switch (obj->instance) {
|
||||
case 0:
|
||||
|
@ -96,6 +97,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
pinmap_pinout(sclk, PinMap_SPI_SCLK);
|
||||
if (ssel != NC) {
|
||||
pinmap_pinout(ssel, PinMap_SPI_SSEL);
|
||||
obj->ssel_num = pinmap_function(ssel, PinMap_SPI_SSEL) >> SSELNUM_SHIFT;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,6 +130,7 @@ void spi_format(spi_t *obj, int bits, int mode, int slave)
|
|||
master_config.polarity = (mode & 0x2) ? kSPI_ClockPolarityActiveLow : kSPI_ClockPolarityActiveHigh;
|
||||
master_config.phase = (mode & 0x1) ? kSPI_ClockPhaseSecondEdge : kSPI_ClockPhaseFirstEdge;
|
||||
master_config.direction = kSPI_MsbFirst;
|
||||
master_config.sselNum = obj->ssel_num;
|
||||
if (baud_rate > 0) {
|
||||
master_config.baudRate_Bps = baud_rate;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ typedef enum {
|
|||
ADC0_SE11 = 11,
|
||||
} ADCName;
|
||||
|
||||
|
||||
#define SSELNUM_SHIFT 16
|
||||
typedef enum {
|
||||
SPI_0 = Flexcomm3,
|
||||
SPI_1 = Flexcomm5
|
||||
|
|
|
@ -90,8 +90,8 @@ const PinMap PinMap_SPI_MISO[] = {
|
|||
|
||||
const PinMap PinMap_SPI_SSEL[] = {
|
||||
{P0_14, SPI_0, 1},
|
||||
{P1_1, SPI_1, 4},
|
||||
{P1_2, SPI_1, 4},
|
||||
{P1_1, SPI_1, ((2 << SSELNUM_SHIFT) | 4)},
|
||||
{P1_2, SPI_1, ((3 << SSELNUM_SHIFT) | 4)},
|
||||
{NC , NC , 0}
|
||||
};
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ typedef enum {
|
|||
CAN_1 = 1
|
||||
} CANName;
|
||||
|
||||
#define SSELNUM_SHIFT 16
|
||||
typedef enum {
|
||||
SPI_0 = Flexcomm3,
|
||||
SPI_1 = Flexcomm7,
|
||||
|
|
|
@ -113,8 +113,8 @@ const PinMap PinMap_SPI_MISO[] = {
|
|||
|
||||
const PinMap PinMap_SPI_SSEL[] = {
|
||||
{P0_4, SPI_0, 8},
|
||||
{P1_20, SPI_1, 1},
|
||||
{P1_1, SPI_2, 5},
|
||||
{P1_20, SPI_1, ((1 << SSELNUM_SHIFT) | 1)},
|
||||
{P1_1, SPI_2, ((1 << SSELNUM_SHIFT) | 5)},
|
||||
{NC , NC , 0}
|
||||
};
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ typedef enum {
|
|||
CAN_1 = 1
|
||||
} CANName;
|
||||
|
||||
#define SSELNUM_SHIFT 16
|
||||
typedef enum {
|
||||
SPI_0 = Flexcomm0,
|
||||
SPI_2 = Flexcomm2,
|
||||
|
|
|
@ -100,6 +100,7 @@ typedef enum {
|
|||
CAN_1 = 1
|
||||
} CANName;
|
||||
|
||||
#define SSELNUM_SHIFT 16
|
||||
typedef enum {
|
||||
SPI_0 = Flexcomm3,
|
||||
SPI_1 = Flexcomm9
|
||||
|
|
|
@ -107,7 +107,7 @@ const PinMap PinMap_SPI_MISO[] = {
|
|||
const PinMap PinMap_SPI_SSEL[] = {
|
||||
{P0_1, SPI_0, 2},
|
||||
{P3_30, SPI_1, 1},
|
||||
{P4_6, SPI_1, 2},
|
||||
{P4_6, SPI_1, ((1 << SSELNUM_SHIFT) | 2)},
|
||||
{NC , NC , 0}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue