generated from Weckyy702/pico-nix
Rebuild DAC and first functioning PoC
By just counting the gpio mask up, we can see the different voltages update they should :^)
This commit is contained in:
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
include(pico_sdk_import.cmake)
|
||||
|
||||
project(PicoNix C CXX ASM)
|
||||
project(PicoVGA C CXX ASM)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
@@ -15,7 +15,9 @@ add_executable(main
|
||||
|
||||
target_link_libraries(main
|
||||
pico_stdlib
|
||||
pico_cyw43_arch_none
|
||||
hardware_gpio
|
||||
)
|
||||
|
||||
pico_add_extra_outputs(main)
|
||||
pico_enable_stdio_usb(main 0)
|
||||
pico_enable_stdio_uart(main 1)
|
||||
|
||||
33
src/main.cpp
33
src/main.cpp
@@ -1,22 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include "pico/cyw43_arch.h"
|
||||
#include "hardware/gpio.h"
|
||||
#include "pico/stdlib.h"
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <pico/time.h>
|
||||
|
||||
constexpr static uint start_pin = 2;
|
||||
constexpr static uint pin_mask = (0xFFF) << start_pin;
|
||||
|
||||
int main() {
|
||||
stdio_init_all();
|
||||
if (cyw43_arch_init()) {
|
||||
printf("Wi-Fi init failed");
|
||||
return -1;
|
||||
|
||||
for (uint offset{}; offset != 14; ++offset) {
|
||||
auto const pin = start_pin + offset;
|
||||
gpio_init(pin);
|
||||
gpio_set_dir(pin, GPIO_OUT);
|
||||
}
|
||||
while (true) {
|
||||
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);
|
||||
sleep_ms(500);
|
||||
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);
|
||||
sleep_ms(500);
|
||||
|
||||
for (uint16_t pixel{};; ++pixel) {
|
||||
auto const set_mask = (pixel & 0xFFF) << start_pin;
|
||||
printf("Set mask=%03x", pixel);
|
||||
gpio_put_masked(pin_mask, set_mask);
|
||||
sleep_ms(100);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user