Lines Matching refs:obj

31 void SpiInit( Spi_t *obj, SpiId_t spiId, PinNames mosi, PinNames miso, PinNames sclk, PinNames nss )  in SpiInit()  argument
35 obj->SpiId = spiId; in SpiInit()
45 … GpioInit( &obj->Mosi, mosi, PIN_ALTERNATE_FCT, PIN_PUSH_PULL, PIN_PULL_DOWN, GPIO_AF5_SPI1 ); in SpiInit()
46 … GpioInit( &obj->Miso, miso, PIN_ALTERNATE_FCT, PIN_PUSH_PULL, PIN_PULL_DOWN, GPIO_AF5_SPI1 ); in SpiInit()
47 … GpioInit( &obj->Sclk, sclk, PIN_ALTERNATE_FCT, PIN_PUSH_PULL, PIN_PULL_DOWN, GPIO_AF5_SPI1 ); in SpiInit()
48 GpioInit( &obj->Nss, nss, PIN_ALTERNATE_FCT, PIN_PUSH_PULL, PIN_PULL_UP, GPIO_AF5_SPI1 ); in SpiInit()
58 … GpioInit( &obj->Mosi, mosi, PIN_ALTERNATE_FCT, PIN_PUSH_PULL, PIN_PULL_DOWN, GPIO_AF5_SPI2 ); in SpiInit()
59 … GpioInit( &obj->Miso, miso, PIN_ALTERNATE_FCT, PIN_PUSH_PULL, PIN_PULL_DOWN, GPIO_AF5_SPI2 ); in SpiInit()
60 … GpioInit( &obj->Sclk, sclk, PIN_ALTERNATE_FCT, PIN_PUSH_PULL, PIN_PULL_DOWN, GPIO_AF5_SPI2 ); in SpiInit()
61 GpioInit( &obj->Nss, nss, PIN_ALTERNATE_FCT, PIN_PUSH_PULL, PIN_PULL_UP, GPIO_AF5_SPI2 ); in SpiInit()
67 SpiFormat( obj, 8, SPI_POLARITY_LOW, SPI_PHASE_1EDGE, 0 ); in SpiInit()
71 SpiFormat( obj, 8, SPI_POLARITY_LOW, SPI_PHASE_1EDGE, 1 ); in SpiInit()
73 SpiFrequency( obj, 10000000 ); in SpiInit()
80 void SpiDeInit( Spi_t *obj ) in SpiDeInit() argument
82 HAL_SPI_DeInit( &SpiHandle[obj->SpiId] ); in SpiDeInit()
84 GpioInit( &obj->Mosi, obj->Mosi.pin, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); in SpiDeInit()
85 GpioInit( &obj->Miso, obj->Miso.pin, PIN_OUTPUT, PIN_PUSH_PULL, PIN_PULL_DOWN, 0 ); in SpiDeInit()
86 GpioInit( &obj->Sclk, obj->Sclk.pin, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); in SpiDeInit()
87 GpioInit( &obj->Nss, obj->Nss.pin, PIN_OUTPUT, PIN_PUSH_PULL, PIN_PULL_UP, 1 ); in SpiDeInit()
90 void SpiFormat( Spi_t *obj, int8_t bits, int8_t cpol, int8_t cpha, int8_t slave ) in SpiFormat() argument
92 SpiHandle[obj->SpiId].Init.Direction = SPI_DIRECTION_2LINES; in SpiFormat()
95 SpiHandle[obj->SpiId].Init.DataSize = SPI_DATASIZE_8BIT; in SpiFormat()
99 SpiHandle[obj->SpiId].Init.DataSize = SPI_DATASIZE_16BIT; in SpiFormat()
101 SpiHandle[obj->SpiId].Init.CLKPolarity = cpol; in SpiFormat()
102 SpiHandle[obj->SpiId].Init.CLKPhase = cpha; in SpiFormat()
103 SpiHandle[obj->SpiId].Init.FirstBit = SPI_FIRSTBIT_MSB; in SpiFormat()
104 SpiHandle[obj->SpiId].Init.TIMode = SPI_TIMODE_DISABLE; in SpiFormat()
105 SpiHandle[obj->SpiId].Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; in SpiFormat()
106 SpiHandle[obj->SpiId].Init.CRCPolynomial = 7; in SpiFormat()
110 SpiHandle[obj->SpiId].Init.Mode = SPI_MODE_MASTER; in SpiFormat()
114 SpiHandle[obj->SpiId].Init.Mode = SPI_MODE_SLAVE; in SpiFormat()
118 void SpiFrequency( Spi_t *obj, uint32_t hz ) in SpiFrequency() argument
139 SpiHandle[obj->SpiId].Init.BaudRatePrescaler = baudRate; in SpiFrequency()
142 uint16_t SpiInOut( Spi_t *obj, uint16_t outData ) in SpiInOut() argument
146 if( ( obj == NULL ) || ( SpiHandle[obj->SpiId].Instance ) == NULL ) in SpiInOut()
151 __HAL_SPI_ENABLE( &SpiHandle[obj->SpiId] ); in SpiInOut()
155 …HAL_SPI_TransmitReceive( &SpiHandle[obj->SpiId], ( uint8_t* )&outData, &rxData, 1, HAL_MAX_DELAY ); in SpiInOut()