kopia lustrzana https://github.com/amedes/pico_tnc
41 wiersze
1.1 KiB
Plaintext
41 wiersze
1.1 KiB
Plaintext
;
|
|
; Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
|
|
;
|
|
; SPDX-License-Identifier: BSD-3-Clause
|
|
;
|
|
|
|
.program pio_dac
|
|
|
|
; Repeatedly get one word of data from the TX FIFO, stalling when the FIFO is
|
|
; empty. Write the least significant bit to the OUT pin group.
|
|
|
|
.wrap_target
|
|
out pins, 1
|
|
.wrap
|
|
|
|
% c-sdk {
|
|
#include "hardware/clocks.h"
|
|
|
|
static inline void pio_dac_program_init(PIO pio, uint sm, uint offset, uint pin, float fs) {
|
|
pio_sm_config c = pio_dac_program_get_default_config(offset);
|
|
|
|
// Map the state machine's OUT pin group to one pin, namely the `pin`
|
|
// parameter to this function.
|
|
sm_config_set_out_shift(&c, true, true, 32);
|
|
sm_config_set_out_pins(&c, pin, 1);
|
|
sm_config_set_clkdiv(&c, (float)clock_get_hz(clk_sys) / fs);
|
|
|
|
// Set this pin's GPIO function (connect PIO to the pad)
|
|
pio_gpio_init(pio, pin);
|
|
|
|
// Set the pin direction to output at the PIO
|
|
pio_sm_set_consecutive_pindirs(pio, sm, pin, 1, true);
|
|
|
|
// Load our configuration, and jump to the start of the program
|
|
pio_sm_init(pio, sm, offset, &c);
|
|
|
|
// Set the state machine running
|
|
pio_sm_set_enabled(pio, sm, true);
|
|
}
|
|
%}
|