Skip to content

Commit 28f1a4a

Browse files
committed
oled: Use DMA to update screen
1 parent 8bdd80f commit 28f1a4a

30 files changed

+1363
-319
lines changed

external/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ if(CMAKE_CROSSCOMPILING)
6666
asf4-drivers/hal/src/hal_delay.c
6767
asf4-drivers/hal/src/hal_timer.c
6868
asf4-drivers/hal/src/hal_usb_device.c
69+
asf4-drivers/hal/src/hal_spi_m_dma.c
6970
asf4-drivers/hal/src/hal_rand_sync.c
7071
asf4-drivers/hal/src/hal_flash.c
7172
asf4-drivers/hal/src/hal_pac.c
@@ -75,6 +76,7 @@ if(CMAKE_CROSSCOMPILING)
7576
asf4-drivers/hal/src/hal_usart_async.c
7677
asf4-drivers/hal/utils/src/utils_ringbuffer.c
7778
asf4-drivers/hpl/gclk/hpl_gclk.c
79+
asf4-drivers/hpl/dmac/hpl_dmac.c
7880
asf4-drivers/hpl/oscctrl/hpl_oscctrl.c
7981
asf4-drivers/hpl/mclk/hpl_mclk.c
8082
asf4-drivers/hpl/osc32kctrl/hpl_osc32kctrl.c

external/asf4-drivers/Config/hpl_dmac_config.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// <i> Indicates whether dmac is enabled or not
99
// <id> dmac_enable
1010
#ifndef CONF_DMAC_ENABLE
11-
#define CONF_DMAC_ENABLE 0
11+
#define CONF_DMAC_ENABLE 1
1212
#endif
1313

1414
// <q> Priority Level 0
@@ -105,7 +105,7 @@
105105
// <e> Channel 0 settings
106106
// <id> dmac_channel_0_settings
107107
#ifndef CONF_DMAC_CHANNEL_0_SETTINGS
108-
#define CONF_DMAC_CHANNEL_0_SETTINGS 0
108+
#define CONF_DMAC_CHANNEL_0_SETTINGS 1
109109
#endif
110110

111111
// <q> Channel Run in Standby
@@ -122,7 +122,7 @@
122122
// <i> Defines the trigger action used for a transfer
123123
// <id> dmac_trigact_0
124124
#ifndef CONF_DMAC_TRIGACT_0
125-
#define CONF_DMAC_TRIGACT_0 0
125+
#define CONF_DMAC_TRIGACT_0 2
126126
#endif
127127

128128
// <o> Trigger source
@@ -214,7 +214,7 @@
214214
// <i> Defines the peripheral trigger which is source of the transfer
215215
// <id> dmac_trifsrc_0
216216
#ifndef CONF_DMAC_TRIGSRC_0
217-
#define CONF_DMAC_TRIGSRC_0 0
217+
#define CONF_DMAC_TRIGSRC_0 11
218218
#endif
219219

220220
// <o> Channel Arbitration Level
@@ -277,14 +277,14 @@
277277
// <i> Defines whether source or destination addresses are using the step size settings
278278
// <id> dmac_stepsel_0
279279
#ifndef CONF_DMAC_STEPSEL_0
280-
#define CONF_DMAC_STEPSEL_0 0
280+
#define CONF_DMAC_STEPSEL_0 1
281281
#endif
282282

283283
// <q> Source Address Increment
284284
// <i> Indicates whether the source address incrementation is enabled or not
285285
// <id> dmac_srcinc_0
286286
#ifndef CONF_DMAC_SRCINC_0
287-
#define CONF_DMAC_SRCINC_0 0
287+
#define CONF_DMAC_SRCINC_0 1
288288
#endif
289289

290290
// <q> Destination Address Increment

external/asf4-drivers/Config/hpl_sercom_config.h

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,185 @@
235235
#define CONF_SERCOM_0_USART_RECEIVE_PULSE_LENGTH 0
236236
#endif
237237
#endif
238+
//
239+
// Enable configuration of module
240+
#ifndef CONF_SERCOM_3_SPI_ENABLE
241+
#define CONF_SERCOM_3_SPI_ENABLE 1
242+
#endif
243+
244+
//<o> SPI DMA TX Channel <0-32>
245+
//<i> This defines DMA channel to be used
246+
//<id> spi_master_dma_tx_channel
247+
#ifndef CONF_SERCOM_3_SPI_M_DMA_TX_CHANNEL
248+
#define CONF_SERCOM_3_SPI_M_DMA_TX_CHANNEL 0
249+
#endif
250+
251+
// <e> SPI RX Channel Enable
252+
// <id> spi_master_rx_channel
253+
#ifndef CONF_SERCOM_3_SPI_RX_CHANNEL
254+
#define CONF_SERCOM_3_SPI_RX_CHANNEL 0
255+
#endif
256+
257+
//<o> DMA Channel <0-32>
258+
//<i> This defines DMA channel to be used
259+
//<id> spi_master_dma_rx_channel
260+
#ifndef CONF_SERCOM_3_SPI_M_DMA_RX_CHANNEL
261+
#define CONF_SERCOM_3_SPI_M_DMA_RX_CHANNEL 1
262+
#endif
263+
264+
// </e>
265+
266+
// Set module in SPI Master mode
267+
#ifndef CONF_SERCOM_3_SPI_MODE
268+
#define CONF_SERCOM_3_SPI_MODE 0x03
269+
#endif
270+
271+
// <h> Basic Configuration
272+
273+
// <q> Receive buffer enable
274+
// <i> Enable receive buffer to receive data from slave (RXEN)
275+
// <id> spi_master_rx_enable
276+
#ifndef CONF_SERCOM_3_SPI_RXEN
277+
#define CONF_SERCOM_3_SPI_RXEN 0x0
278+
#endif
279+
280+
// <o> Character Size
281+
// <i> Bit size for all characters sent over the SPI bus (CHSIZE)
282+
// <0x0=>8 bits
283+
// <0x1=>9 bits
284+
// <id> spi_master_character_size
285+
#ifndef CONF_SERCOM_3_SPI_CHSIZE
286+
#define CONF_SERCOM_3_SPI_CHSIZE 0x0
287+
#endif
288+
// <o> Baud rate <1-18000000>
289+
// <i> The SPI data transfer rate
290+
// <id> spi_master_baud_rate
291+
#ifndef CONF_SERCOM_3_SPI_BAUD
292+
#define CONF_SERCOM_3_SPI_BAUD 3000000
293+
#endif
294+
295+
// </h>
296+
297+
// <e> Advanced Configuration
298+
// <id> spi_master_advanced
299+
#ifndef CONF_SERCOM_3_SPI_ADVANCED
300+
#define CONF_SERCOM_3_SPI_ADVANCED 1
301+
#endif
302+
303+
// <o> Dummy byte <0x00-0x1ff>
304+
// <id> spi_master_dummybyte
305+
// <i> Dummy byte used when reading data from the slave without sending any data
306+
#ifndef CONF_SERCOM_3_SPI_DUMMYBYTE
307+
#define CONF_SERCOM_3_SPI_DUMMYBYTE 0x1ff
308+
#endif
309+
310+
// <o> Data Order
311+
// <0=>MSB first
312+
// <1=>LSB first
313+
// <i> I least significant or most significant bit is shifted out first (DORD)
314+
// <id> spi_master_arch_dord
315+
#ifndef CONF_SERCOM_3_SPI_DORD
316+
#define CONF_SERCOM_3_SPI_DORD 0x0
317+
#endif
318+
319+
// <o> Clock Polarity
320+
// <0=>SCK is low when idle
321+
// <1=>SCK is high when idle
322+
// <i> Determines if the leading edge is rising or falling with a corresponding opposite edge at the trailing edge. (CPOL)
323+
// <id> spi_master_arch_cpol
324+
#ifndef CONF_SERCOM_3_SPI_CPOL
325+
#define CONF_SERCOM_3_SPI_CPOL 0x0
326+
#endif
327+
328+
// <o> Clock Phase
329+
// <0x0=>Sample input on leading edge
330+
// <0x1=>Sample input on trailing edge
331+
// <i> Determines if input data is sampled on leading or trailing SCK edge. (CPHA)
332+
// <id> spi_master_arch_cpha
333+
#ifndef CONF_SERCOM_3_SPI_CPHA
334+
#define CONF_SERCOM_3_SPI_CPHA 0x0
335+
#endif
336+
337+
// <o> Immediate Buffer Overflow Notification
338+
// <i> Controls when OVF is asserted (IBON)
339+
// <0x0=>In data stream
340+
// <0x1=>On buffer overflow
341+
// <id> spi_master_arch_ibon
342+
#ifndef CONF_SERCOM_3_SPI_IBON
343+
#define CONF_SERCOM_3_SPI_IBON 0x0
344+
#endif
345+
346+
// <q> Run in stand-by
347+
// <i> Module stays active in stand-by sleep mode. (RUNSTDBY)
348+
// <id> spi_master_arch_runstdby
349+
#ifndef CONF_SERCOM_3_SPI_RUNSTDBY
350+
#define CONF_SERCOM_3_SPI_RUNSTDBY 0x0
351+
#endif
352+
353+
// <o> Debug Stop Mode
354+
// <i> Behavior of the baud-rate generator when CPU is halted by external debugger. (DBGSTOP)
355+
// <0=>Keep running
356+
// <1=>Halt
357+
// <id> spi_master_arch_dbgstop
358+
#ifndef CONF_SERCOM_3_SPI_DBGSTOP
359+
#define CONF_SERCOM_3_SPI_DBGSTOP 0
360+
#endif
361+
362+
// </e>
363+
364+
// Address mode disabled in master mode
365+
#ifndef CONF_SERCOM_3_SPI_AMODE_EN
366+
#define CONF_SERCOM_3_SPI_AMODE_EN 0
367+
#endif
368+
369+
#ifndef CONF_SERCOM_3_SPI_AMODE
370+
#define CONF_SERCOM_3_SPI_AMODE 0
371+
#endif
372+
373+
#ifndef CONF_SERCOM_3_SPI_ADDR
374+
#define CONF_SERCOM_3_SPI_ADDR 0
375+
#endif
376+
377+
#ifndef CONF_SERCOM_3_SPI_ADDRMASK
378+
#define CONF_SERCOM_3_SPI_ADDRMASK 0
379+
#endif
380+
381+
#ifndef CONF_SERCOM_3_SPI_SSDE
382+
#define CONF_SERCOM_3_SPI_SSDE 0
383+
#endif
384+
385+
#ifndef CONF_SERCOM_3_SPI_MSSEN
386+
#define CONF_SERCOM_3_SPI_MSSEN 0x0
387+
#endif
388+
389+
#ifndef CONF_SERCOM_3_SPI_PLOADEN
390+
#define CONF_SERCOM_3_SPI_PLOADEN 0
391+
#endif
392+
393+
// <o> Receive Data Pinout
394+
// <0x0=>PAD[0]
395+
// <0x1=>PAD[1]
396+
// <0x2=>PAD[2]
397+
// <0x3=>PAD[3]
398+
// <id> spi_master_rxpo
399+
#ifndef CONF_SERCOM_3_SPI_RXPO
400+
#define CONF_SERCOM_3_SPI_RXPO 2
401+
#endif
402+
403+
// <o> Transmit Data Pinout
404+
// <0x0=>PAD[0,1]_DO_SCK
405+
// <0x1=>PAD[2,3]_DO_SCK
406+
// <0x2=>PAD[3,1]_DO_SCK
407+
// <0x3=>PAD[0,3]_DO_SCK
408+
// <id> spi_master_txpo
409+
#ifndef CONF_SERCOM_3_SPI_TXPO
410+
#define CONF_SERCOM_3_SPI_TXPO 0
411+
#endif
412+
413+
// Calculate baud register value from requested baudrate value
414+
#ifndef CONF_SERCOM_3_SPI_BAUD_RATE
415+
#define CONF_SERCOM_3_SPI_BAUD_RATE ((float)CONF_GCLK_SERCOM3_CORE_FREQUENCY / (float)(2 * CONF_SERCOM_3_SPI_BAUD)) - 1
416+
#endif
238417

239418
#include <peripheral_clk_config.h>
240419

0 commit comments

Comments
 (0)