Bug fixes and new examples Co-authored-by: Paulo Marques <pm@quant-insight.com> Co-authored-by: martin <admin@crossleys.biz> Co-authored-by: matiasilva <matias.silva@raspberrypi.com> Co-authored-by: Uri Shaked <uri@urishaked.com> Co-authored-by: Diego Solano <diegosolano@gmail.com> Co-authored-by: Andrew Scheller <andrew.scheller@raspberrypi.com> Co-authored-by: Adrian Hesketh <a-h@users.noreply.github.com> Co-authored-by: Emircan Gündoğdu <58917386+emircangun@users.noreply.github.com> Co-authored-by: Josef Wegner <80200012+josefwegner@users.noreply.github.com> Co-authored-by: pmarques-dev <72901351+pmarques-dev@users.noreply.github.com> Co-authored-by: Paulo Marques <pm@quant-insight.com> Co-authored-by: mjcross <mjcross@users.noreply.github.com> Co-authored-by: martin <admin@crossleys.biz>
36 lines
903 B
C
36 lines
903 B
C
/**
|
|
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "pico/stdlib.h"
|
|
#include "hardware/pio.h"
|
|
#include "hardware/clocks.h"
|
|
#include "blink.pio.h"
|
|
|
|
void blink_pin_forever(PIO pio, uint sm, uint offset, uint pin, uint freq);
|
|
|
|
int main() {
|
|
setup_default_uart();
|
|
|
|
// todo get free sm
|
|
PIO pio = pio0;
|
|
uint offset = pio_add_program(pio, &blink_program);
|
|
printf("Loaded program at %d\n", offset);
|
|
|
|
blink_pin_forever(pio, 0, offset, 0, 3);
|
|
blink_pin_forever(pio, 1, offset, 6, 4);
|
|
blink_pin_forever(pio, 2, offset, 11, 1);
|
|
}
|
|
|
|
void blink_pin_forever(PIO pio, uint sm, uint offset, uint pin, uint freq) {
|
|
blink_program_init(pio, sm, offset, pin);
|
|
pio_sm_set_enabled(pio, sm, true);
|
|
|
|
printf("Blinking pin %d at %d Hz\n", pin, freq);
|
|
pio->txf[sm] = clock_get_hz(clk_sys) / (2 * freq);
|
|
}
|