view modulator.c @ 0:a55e39064a71

First commit of code that compiles. Does nothing like it should but has cmake goo to wrap dat files
author Daniel O'Connor <darius@dons.net.au>
date Mon, 29 Mar 2021 13:48:34 +1030
parents
children 0d653f60dec8
line wrap: on
line source

/******************************************************************
*******************************************************************
**
** This is proprietary unpublished source code, property
** of Genesis Software.  Use or disclosure without prior
** agreement is expressly prohibited.
**
** Copyright (c) 2021 Genesis Software, all rights reserved.
**
*******************************************************************
 ******************************************************************/

/*
** MODULATOR.C
**
** Create modulation shape
**
*/

#include "pico/stdlib.h"
#include "hardware/clocks.h"
#include "hardware/pio.h"

#include "dac.pio.h"

extern void* shaped_trap_dat_size;
extern void* shaped_trap_dat_start;

extern void* sgauss_dat_size;
extern void* sgauss_dat_start;

int
main() {
    int i;
    const uint LED_PIN = PICO_DEFAULT_LED_PIN;

    stdio_init_all();

    gpio_init(LED_PIN);
    gpio_set_dir(LED_PIN, GPIO_OUT);

    // Load the clocked_input program, and configure a free state machine
    // to run the program.
    PIO pio = pio0;
    uint offset = pio_add_program(pio, &dac_program);
    uint sm = pio_claim_unused_sm(pio, true);
    dac_program_init(pio, sm, offset, 4);

    while (true) {
	for (i = 0; i < (int)&shaped_trap_dat_size; i++) {
	    if (*(uint8_t *)shaped_trap_dat_start)
		gpio_put(LED_PIN, 1);
	    else
		gpio_put(LED_PIN, 0);
	    sleep_ms(250);
	}
	for (i = 0; i < (int)&sgauss_dat_size; i++) {
	    if (*(uint8_t *)sgauss_dat_start)
		gpio_put(LED_PIN, 1);
	    else
		gpio_put(LED_PIN, 0);
	    sleep_ms(250);
	}
    }
}