@@ -36,7 +36,7 @@ static inline void lpspi_rx_word_write_bytes(const struct device *dev, size_t of
36
36
struct spi_context * ctx = & data -> ctx ;
37
37
uint8_t num_bytes = MIN (lpspi_data -> word_size_bytes , ctx -> rx_len );
38
38
uint8_t * buf = ctx -> rx_buf + offset ;
39
- uint32_t word = LPSPI_ReadData ( base ) ;
39
+ uint32_t word = base -> RDR ;
40
40
41
41
if (!spi_context_rx_buf_on (ctx ) && spi_context_rx_on (ctx )) {
42
42
/* receive no actual data if rx buf is NULL */
@@ -78,7 +78,7 @@ static inline void lpspi_handle_rx_irq(const struct device *dev)
78
78
uint8_t total_words_read = 0 ;
79
79
uint8_t words_read ;
80
80
81
- LPSPI_ClearStatusFlags ( base , kLPSPI_RxDataReadyFlag ) ;
81
+ base -> SR = LPSPI_SR_RDF_MASK ;
82
82
83
83
LOG_DBG ("RX FIFO: %d, RX BUF: %p" , rx_fsr , ctx -> rx_buf );
84
84
@@ -92,8 +92,8 @@ static inline void lpspi_handle_rx_irq(const struct device *dev)
92
92
LOG_DBG ("RX done %d words to spi buf" , total_words_written );
93
93
94
94
if (spi_context_rx_len_left (ctx ) == 0 ) {
95
- LPSPI_DisableInterrupts ( base , ( uint32_t ) kLPSPI_RxInterruptEnable ) ;
96
- LPSPI_FlushFifo ( base , false, true);
95
+ base -> IER &= ~ LPSPI_IER_RDIE_MASK ;
96
+ base -> CR |= LPSPI_CR_RRF_MASK ; /* flush rx fifo */
97
97
}
98
98
}
99
99
@@ -122,7 +122,7 @@ static inline void lpspi_fill_tx_fifo(const struct device *dev)
122
122
size_t offset ;
123
123
124
124
for (offset = 0 ; offset < bytes_in_xfer ; offset += lpspi_data -> word_size_bytes ) {
125
- LPSPI_WriteData ( base , lpspi_next_tx_word (dev , offset ) );
125
+ base -> TDR = lpspi_next_tx_word (dev , offset );
126
126
}
127
127
128
128
LOG_DBG ("Filled TX FIFO to %d words (%d bytes)" , lpspi_data -> fill_len , offset );
@@ -135,7 +135,7 @@ static void lpspi_fill_tx_fifo_nop(const struct device *dev)
135
135
struct lpspi_driver_data * lpspi_data = (struct lpspi_driver_data * )data -> driver_data ;
136
136
137
137
for (int i = 0 ; i < lpspi_data -> fill_len ; i ++ ) {
138
- LPSPI_WriteData ( base , 0 ) ;
138
+ base -> TDR = 0 ;
139
139
}
140
140
141
141
LOG_DBG ("Filled TX fifo with %d NOPs" , lpspi_data -> fill_len );
@@ -170,10 +170,10 @@ static inline void lpspi_handle_tx_irq(const struct device *dev)
170
170
171
171
spi_context_update_tx (ctx , lpspi_data -> word_size_bytes , lpspi_data -> fill_len );
172
172
173
- LPSPI_ClearStatusFlags ( base , kLPSPI_TxDataRequestFlag ) ;
173
+ base -> SR = LPSPI_SR_TDF_MASK ;
174
174
175
175
if (!spi_context_tx_on (ctx )) {
176
- LPSPI_DisableInterrupts ( base , ( uint32_t ) kLPSPI_TxInterruptEnable ) ;
176
+ base -> IER &= ~ LPSPI_IER_TDIE_MASK ;
177
177
return ;
178
178
}
179
179
@@ -184,16 +184,16 @@ static void lpspi_isr(const struct device *dev)
184
184
{
185
185
LPSPI_Type * base = (LPSPI_Type * )DEVICE_MMIO_NAMED_GET (dev , reg_base );
186
186
const struct spi_mcux_config * config = dev -> config ;
187
- uint32_t status_flags = LPSPI_GetStatusFlags (base );
188
187
struct spi_mcux_data * data = dev -> data ;
189
188
struct lpspi_driver_data * lpspi_data = (struct lpspi_driver_data * )data -> driver_data ;
190
189
struct spi_context * ctx = & data -> ctx ;
190
+ uint32_t status_flags = base -> SR ;
191
191
192
- if (status_flags & kLPSPI_RxDataReadyFlag ) {
192
+ if (status_flags & LPSPI_SR_RDF_MASK ) {
193
193
lpspi_handle_rx_irq (dev );
194
194
}
195
195
196
- if (status_flags & kLPSPI_TxDataRequestFlag ) {
196
+ if (status_flags & LPSPI_SR_TDF_MASK ) {
197
197
lpspi_handle_tx_irq (dev );
198
198
}
199
199
@@ -248,15 +248,15 @@ static int transceive(const struct device *dev, const struct spi_config *spi_cfg
248
248
return ret ;
249
249
}
250
250
251
- LPSPI_FlushFifo (base , true, true);
252
- LPSPI_ClearStatusFlags (base , (uint32_t )kLPSPI_AllStatusFlag );
253
- LPSPI_DisableInterrupts (base , (uint32_t )kLPSPI_AllInterruptEnable );
251
+ base -> CR |= LPSPI_CR_RTF_MASK | LPSPI_CR_RRF_MASK ; /* flush fifos */
252
+ base -> IER = 0 ; /* disable all interrupts */
253
+ base -> FCR = 0 ; /* set watermarks to 0 */
254
+ base -> SR |= LPSPI_INTERRUPT_BITS ;
254
255
255
256
LOG_DBG ("Starting LPSPI transfer" );
256
257
spi_context_cs_control (& data -> ctx , true);
257
258
258
- LPSPI_SetFifoWatermarks (base , 0 , 0 );
259
- LPSPI_Enable (base , true);
259
+ base -> CR |= LPSPI_CR_MEN_MASK ;
260
260
261
261
/* keep the chip select asserted until the end of the zephyr xfer */
262
262
base -> TCR |= LPSPI_TCR_CONT_MASK ;
@@ -266,8 +266,7 @@ static int transceive(const struct device *dev, const struct spi_config *spi_cfg
266
266
/* start the transfer sequence which are handled by irqs */
267
267
lpspi_next_tx_fill (dev );
268
268
269
- LPSPI_EnableInterrupts (base , (uint32_t )kLPSPI_TxInterruptEnable |
270
- (uint32_t )kLPSPI_RxInterruptEnable );
269
+ base -> IER |= LPSPI_IER_TDIE_MASK | LPSPI_IER_RDIE_MASK ;
271
270
272
271
return spi_context_wait_for_completion (& data -> ctx );
273
272
}
0 commit comments