fixup examples based on default pin #define-s and also support them being undefined
This commit is contained in:
committed by
Graham Sanderson
parent
9c7e31b8e7
commit
82b6dc0576
@@ -52,6 +52,9 @@ void dma_handler() {
|
||||
}
|
||||
|
||||
int main() {
|
||||
#ifndef PICO_DEFAULT_LED_PIN
|
||||
#warning dma/channel_irq example requires a board with a regular LED
|
||||
#else
|
||||
// Set up a PIO state machine to serialise our bits
|
||||
uint offset = pio_add_program(pio0, &pio_serialiser_program);
|
||||
pio_serialiser_program_init(pio0, 0, offset, PICO_DEFAULT_LED_PIN, PIO_SERIAL_CLKDIV);
|
||||
@@ -87,5 +90,5 @@ int main() {
|
||||
// time to sit and think about its early retirement -- maybe open a bakery?
|
||||
while (true)
|
||||
tight_loop_contents();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -47,6 +47,9 @@ const struct {uint32_t len; const char *data;} control_blocks[] = {
|
||||
};
|
||||
|
||||
int main() {
|
||||
#ifndef uart_default
|
||||
#warning dma/control_blocks example requires a UART
|
||||
#else
|
||||
stdio_init_all();
|
||||
puts("DMA control block example:");
|
||||
|
||||
@@ -81,7 +84,7 @@ int main() {
|
||||
|
||||
c = dma_channel_get_default_config(data_chan);
|
||||
channel_config_set_transfer_data_size(&c, DMA_SIZE_8);
|
||||
channel_config_set_dreq(&c, DREQ_UART0_TX + 2 * PICO_DEFAULT_UART);
|
||||
channel_config_set_dreq(&c, DREQ_UART0_TX + 2 * uart_get_index(uart_default));
|
||||
// Trigger ctrl_chan when data_chan completes
|
||||
channel_config_set_chain_to(&c, ctrl_chan);
|
||||
// Raise the IRQ flag when 0 is written to a trigger register (end of chain):
|
||||
@@ -90,7 +93,7 @@ int main() {
|
||||
dma_channel_configure(
|
||||
data_chan,
|
||||
&c,
|
||||
&(PICO_DEFAULT_UART ? uart1_hw : uart0_hw)->dr,
|
||||
&uart_get_hw(uart_default)->dr,
|
||||
NULL, // Initial read address and transfer count are unimportant;
|
||||
0, // the control channel will reprogram them each time.
|
||||
false // Don't start yet.
|
||||
@@ -108,4 +111,5 @@ int main() {
|
||||
dma_hw->ints0 = 1u << data_chan;
|
||||
|
||||
puts("DMA finished.");
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user