Initial Release
This commit is contained in:
101
test/kitchen_sink/CMakeLists.txt
Normal file
101
test/kitchen_sink/CMakeLists.txt
Normal file
@ -0,0 +1,101 @@
|
||||
add_library(kitchen_sink_libs INTERFACE)
|
||||
target_sources(kitchen_sink_libs INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c
|
||||
)
|
||||
target_link_libraries(kitchen_sink_libs INTERFACE
|
||||
hardware_adc
|
||||
hardware_clocks
|
||||
hardware_divider
|
||||
hardware_dma
|
||||
hardware_flash
|
||||
hardware_gpio
|
||||
hardware_i2c
|
||||
hardware_interp
|
||||
hardware_irq
|
||||
hardware_pio
|
||||
hardware_pll
|
||||
hardware_pwm
|
||||
hardware_resets
|
||||
hardware_rtc
|
||||
hardware_uart
|
||||
hardware_spi
|
||||
hardware_sync
|
||||
hardware_timer
|
||||
hardware_uart
|
||||
hardware_vreg
|
||||
hardware_watchdog
|
||||
hardware_xosc
|
||||
pico_bit_ops
|
||||
pico_bootrom
|
||||
pico_divider
|
||||
pico_double
|
||||
pico_fix_rp2040_usb_device_enumeration
|
||||
pico_float
|
||||
pico_int64_ops
|
||||
pico_malloc
|
||||
pico_mem_ops
|
||||
pico_multicore
|
||||
pico_platform
|
||||
pico_stdlib
|
||||
pico_sync
|
||||
pico_time
|
||||
pico_util
|
||||
)
|
||||
|
||||
add_library(kitchen_sink_options INTERFACE)
|
||||
|
||||
target_compile_options(kitchen_sink_options INTERFACE
|
||||
-Werror
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wno-unused-parameter
|
||||
-Wno-inline
|
||||
-Wnull-dereference
|
||||
# -pedantic
|
||||
-Wall
|
||||
-Wcast-qual
|
||||
-Wno-deprecated-declarations
|
||||
-Wfloat-equal
|
||||
-Wmissing-format-attribute
|
||||
-Wno-long-long
|
||||
|
||||
# todo not sure these are true, but investigate
|
||||
#-Wpacked
|
||||
|
||||
# todo we have some of these in usb_device_tiny to try to make it more readable.. perhaps doxygen would help here instead
|
||||
#-Wredundant-decls
|
||||
-Wno-shadow
|
||||
-Wno-missing-field-initializers
|
||||
-Wno-missing-braces
|
||||
-Wno-sign-compare
|
||||
-Wno-multichar
|
||||
|
||||
# todo useful but fix later
|
||||
#-Wundef
|
||||
)
|
||||
|
||||
target_compile_definitions(kitchen_sink_libs INTERFACE
|
||||
NDEBUG
|
||||
PICO_AUDIO_DMA_IRQ=1
|
||||
)
|
||||
|
||||
add_executable(kitchen_sink)
|
||||
target_link_libraries(kitchen_sink kitchen_sink_libs kitchen_sink_options)
|
||||
pico_set_program_name(kitchen_sink "Wombat tenticles")
|
||||
pico_add_extra_outputs(kitchen_sink)
|
||||
|
||||
add_executable(kitchen_sink_extra_stdio)
|
||||
target_link_libraries(kitchen_sink_extra_stdio kitchen_sink_libs) # no kitchen_sink_options as TinyUSB has warnings
|
||||
pico_add_extra_outputs(kitchen_sink_extra_stdio)
|
||||
pico_enable_stdio_usb(kitchen_sink_extra_stdio 1)
|
||||
pico_enable_stdio_semihosting(kitchen_sink_extra_stdio 1)
|
||||
|
||||
add_executable(kitchen_sink_copy_to_ram)
|
||||
pico_set_binary_type(kitchen_sink_copy_to_ram copy_to_ram)
|
||||
target_link_libraries(kitchen_sink_copy_to_ram kitchen_sink_libs kitchen_sink_options)
|
||||
pico_add_extra_outputs(kitchen_sink_copy_to_ram)
|
||||
|
||||
add_executable(kitchen_sink_no_flash)
|
||||
pico_set_binary_type(kitchen_sink_no_flash no_flash)
|
||||
target_link_libraries(kitchen_sink_no_flash kitchen_sink_libs kitchen_sink_options)
|
||||
pico_add_extra_outputs(kitchen_sink_no_flash)
|
102
test/kitchen_sink/kitchen_sink.c
Normal file
102
test/kitchen_sink/kitchen_sink.c
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico/time.h"
|
||||
#include "hardware/dma.h"
|
||||
#include "pico/bit_ops.h"
|
||||
#include "hardware/i2c.h"
|
||||
#include "hardware/pwm.h"
|
||||
#include "hardware/pio.h"
|
||||
#include "hardware/irq.h"
|
||||
#include "hardware/timer.h"
|
||||
#include "pico/divider.h"
|
||||
#include "pico/critical_section.h"
|
||||
#include "pico/binary_info.h"
|
||||
|
||||
bi_decl(bi_block_device(
|
||||
BINARY_INFO_MAKE_TAG('K', 'S'),
|
||||
"foo",
|
||||
0x80000,
|
||||
0x40000,
|
||||
NULL,
|
||||
BINARY_INFO_BLOCK_DEV_FLAG_READ | BINARY_INFO_BLOCK_DEV_FLAG_WRITE |
|
||||
BINARY_INFO_BLOCK_DEV_FLAG_PT_UNKNOWN));
|
||||
|
||||
void my_timer(uint i) {
|
||||
puts("XXXX timer");
|
||||
}
|
||||
|
||||
//#pragma GCC push_options
|
||||
//#pragma GCC optimize ("O3")
|
||||
|
||||
uint32_t *foo = (uint32_t *) 200;
|
||||
|
||||
uint32_t dma_to = 0;
|
||||
uint32_t dma_from = 0xaaaa5555;
|
||||
|
||||
void spiggle() {
|
||||
dma_channel_config c = dma_channel_get_default_config(1);
|
||||
channel_config_set_bswap(&c, true);
|
||||
channel_config_set_transfer_data_size(&c, DMA_SIZE_16);
|
||||
channel_config_set_ring(&c, true, 13);
|
||||
dma_channel_set_config(1, &c, false);
|
||||
dma_channel_transfer_from_buffer_now(1, foo, 23);
|
||||
}
|
||||
|
||||
void __isr dma_handler_a() {
|
||||
printf("HELLO A\n");
|
||||
if (dma_hw->ints1 & 1) {
|
||||
dma_hw->ints1 = 1;
|
||||
printf("A WINS DMA_TO %08x\n", (uint) dma_to);
|
||||
irq_remove_handler(DMA_IRQ_1, dma_handler_a);
|
||||
}
|
||||
}
|
||||
|
||||
void __isr dma_handler_b() {
|
||||
printf("HELLO B\n");
|
||||
if (dma_hw->ints1 & 1) {
|
||||
dma_hw->ints1 = 1;
|
||||
printf("B WINS DNA_TO %08x\n", (uint) dma_to);
|
||||
// irq_remove_handler(DMA_IRQ_1, dma_handler_b);
|
||||
}
|
||||
}
|
||||
|
||||
//#pragma GCC pop_options
|
||||
|
||||
int main() {
|
||||
spiggle();
|
||||
|
||||
stdio_init_all();
|
||||
|
||||
printf("HI %d\n", (int)time_us_32());
|
||||
puts("Hello Everything!");
|
||||
puts("Hello Everything2!");
|
||||
|
||||
irq_add_shared_handler(DMA_IRQ_1, dma_handler_a, 0x80);
|
||||
irq_add_shared_handler(DMA_IRQ_1, dma_handler_b, 0xC0);
|
||||
|
||||
dma_channel_config config = dma_channel_get_default_config(0);
|
||||
// set_exclusive_irq_handler(DMA_IRQ_1, dma_handler_a);
|
||||
dma_channel_set_irq1_enabled(0, true);
|
||||
irq_set_enabled(DMA_IRQ_1, true);
|
||||
dma_channel_configure(0, &config, &dma_to, &dma_from, 1, true);
|
||||
dma_channel_set_config(0, &config, false);
|
||||
|
||||
// timer_start_ms(2, 2000, my_timer);
|
||||
for (int i = 0; i < 20; i++) {
|
||||
puts("sleepy");
|
||||
sleep_ms(1000);
|
||||
dma_channel_configure(0, &config, &dma_to, &dma_from, 1, true);
|
||||
if (i==3) {
|
||||
irq_remove_handler(DMA_IRQ_1, dma_handler_a);
|
||||
}
|
||||
if (i==2) {
|
||||
irq_remove_handler(DMA_IRQ_1, dma_handler_b);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user