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