mirror of
https://github.com/halleysfifthinc/AVCLAN-Mockingboard.git
synced 2026-09-25 13:22:06 +00:00
Add ~empty implementation of HAL for pico2
This commit is contained in:
+4
-2
@@ -19,12 +19,14 @@ Checks: |
|
|||||||
-readability-function-cognitive-complexity,
|
-readability-function-cognitive-complexity,
|
||||||
-misc-non-private-member-variables-in-classes
|
-misc-non-private-member-variables-in-classes
|
||||||
WarningsAsErrors: ""
|
WarningsAsErrors: ""
|
||||||
ExcludeHeaderFilterRegex: 'out/build'
|
ExcludeHeaderFilterRegex: "out/build"
|
||||||
HeaderFilterRegex: '^src/.*'
|
HeaderFilterRegex: "^src/.*"
|
||||||
SystemHeaders: false
|
SystemHeaders: false
|
||||||
# AnalyzeTemporaryDtors: false
|
# AnalyzeTemporaryDtors: false
|
||||||
FormatStyle: none
|
FormatStyle: none
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
|
- key: modernize-deprecated-headers.CheckHeaderFile
|
||||||
|
value: "false"
|
||||||
- key: readability-magic-numbers.IgnorePowersOf2IntegerValues
|
- key: readability-magic-numbers.IgnorePowersOf2IntegerValues
|
||||||
value: "true"
|
value: "true"
|
||||||
- key: readability-magic-numbers.IgnoredIntegerValues
|
- key: readability-magic-numbers.IgnoredIntegerValues
|
||||||
|
|||||||
+15
-10
@@ -28,16 +28,6 @@ set(CMAKE_CXX_STANDARD 23)
|
|||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
add_compile_options(
|
|
||||||
-Wall -Wswitch-enum -Werror
|
|
||||||
|
|
||||||
# Debug must not be -O0: both the vendored usart.h and avr-libc's
|
|
||||||
# <util/delay.h> #warning when __OPTIMIZE__ is undefined, and -Werror makes
|
|
||||||
# that fatal.
|
|
||||||
$<$<CONFIG:Debug>:-Og>
|
|
||||||
$<$<CONFIG:Debug>:-fanalyzer>
|
|
||||||
$<$<CONFIG:Debug>:-Wno-analyzer-use-of-uninitialized-value>)
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "13")
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "13")
|
||||||
message(FATAL_ERROR "This project requires at least GCC v13")
|
message(FATAL_ERROR "This project requires at least GCC v13")
|
||||||
@@ -78,6 +68,21 @@ add_library(avclan STATIC
|
|||||||
src/avclan/bus.cc
|
src/avclan/bus.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(avclan PUBLIC
|
||||||
|
AVCLAN_FRAME_POOL_N=${AVCLAN_FRAME_POOL_N}
|
||||||
|
AVCLAN_MSG_QUEUE_SIZE=${AVCLAN_MSG_QUEUE_SIZE}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_options(avclan PUBLIC
|
||||||
|
-Wall -Wswitch-enum -Werror
|
||||||
|
|
||||||
|
# Debug must not be -O0: both the vendored usart.h and avr-libc's
|
||||||
|
# <util/delay.h> #warning when __OPTIMIZE__ is undefined, and -Werror makes
|
||||||
|
# that fatal.
|
||||||
|
$<$<CONFIG:Debug>:-Og>
|
||||||
|
$<$<CONFIG:Debug>:-fanalyzer>
|
||||||
|
$<$<CONFIG:Debug>:-Wno-analyzer-use-of-uninitialized-value>)
|
||||||
|
|
||||||
# avclan exports its public generic headers (src/avclan) to consumers and
|
# avclan exports its public generic headers (src/avclan) to consumers and
|
||||||
# reaches into src/ for sibling headers (stdio.h, board.h) during its own
|
# reaches into src/ for sibling headers (stdio.h, board.h) during its own
|
||||||
# build. The selected target adds its own per-target include path.
|
# build. The selected target adds its own per-target include path.
|
||||||
|
|||||||
+2
-4
@@ -61,7 +61,7 @@
|
|||||||
},
|
},
|
||||||
"environment": {
|
"environment": {
|
||||||
"PICO_PLATFORM": "rp2350-arm-s",
|
"PICO_PLATFORM": "rp2350-arm-s",
|
||||||
"PICO_BOARD": "pico2"
|
"PICO_BOARD": "pimoroni_pico_plus2w_rp2350"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -71,9 +71,7 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"generator": "Ninja",
|
"generator": "Ninja",
|
||||||
"environment": {
|
"environment": {
|
||||||
"PICO_COMPILER": "pico_arm_gcc",
|
"PICO_COMPILER": "pico_arm_gcc"
|
||||||
"CC": "/usr/bin/gcc-15",
|
|
||||||
"CXX": "/usr/bin/g++-15"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -150,7 +150,6 @@ target_compile_definitions(avclan PUBLIC
|
|||||||
__CLK_PRESCALE_DIV=__${CLK_PRESCALE_DIV}
|
__CLK_PRESCALE_DIV=__${CLK_PRESCALE_DIV}
|
||||||
TCB_CLKSEL=${TCB_CLKSEL}
|
TCB_CLKSEL=${TCB_CLKSEL}
|
||||||
RTC_STATUS_PERIOD_MS=${RTC_STATUS_PERIOD_MS}
|
RTC_STATUS_PERIOD_MS=${RTC_STATUS_PERIOD_MS}
|
||||||
AVCLAN_FRAME_POOL_N=${AVCLAN_FRAME_POOL_N}
|
|
||||||
)
|
)
|
||||||
target_compile_options(avclan PUBLIC
|
target_compile_options(avclan PUBLIC
|
||||||
--param=min-pagesize=0
|
--param=min-pagesize=0
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
list(APPEND PICO_CONFIG_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/pimoroni_pico_plus2w_rp2350.h)
|
||||||
|
pico_sdk_init()
|
||||||
|
|
||||||
|
target_sources(avclan PRIVATE
|
||||||
|
phy.cc
|
||||||
|
media.cc
|
||||||
|
cd_timer.cc
|
||||||
|
board.cc
|
||||||
|
stdio.cc
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(avclan PUBLIC
|
||||||
|
pico_stdlib pico_stdio_usb
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(mockingboard_pico
|
||||||
|
${avclan-mockingboard_SOURCE_DIR}/src/sniffer.cc
|
||||||
|
)
|
||||||
|
target_link_libraries(mockingboard_pico PUBLIC
|
||||||
|
avclan
|
||||||
|
)
|
||||||
|
|
||||||
|
# Silence warnings in TinyUSB, and only there.
|
||||||
|
file(GLOB_RECURSE _tinyusb_sources ${PICO_TINYUSB_PATH}/src/*.c)
|
||||||
|
set_source_files_properties(${_tinyusb_sources}
|
||||||
|
TARGET_DIRECTORY avclan mockingboard_pico
|
||||||
|
PROPERTIES COMPILE_OPTIONS "-w")
|
||||||
|
unset(_tinyusb_sources)
|
||||||
|
|
||||||
|
pico_add_extra_outputs(mockingboard_pico)
|
||||||
|
pico_set_float_implementation(mockingboard_pico none)
|
||||||
|
pico_set_double_implementation(mockingboard_pico none)
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
#include "hal/board.h"
|
||||||
|
|
||||||
|
extern "C" void board_init() {}
|
||||||
|
|
||||||
|
extern "C" void board_enable_interrupts() {}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#include "hal/cd_timer.h"
|
||||||
|
|
||||||
|
extern "C" void cdtimer_init(void *ptr, void(clbk)(void *),
|
||||||
|
bool(isplay)(void *)) {}
|
||||||
|
|
||||||
|
extern "C" void cdtimer_reset() {}
|
||||||
|
|
||||||
|
extern "C" void cdtimer_restore() {}
|
||||||
|
|
||||||
|
extern "C" void cdtimer_disable() {}
|
||||||
|
|
||||||
|
volatile bool cdtimer_pending_flag;
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#include "hal/media.h"
|
||||||
|
|
||||||
|
extern "C" void media_init(void) {}
|
||||||
|
|
||||||
|
extern "C" void media_action(MediaAction fn) {}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
extern "C" bool media_mic_toggle(void) { return false; }
|
||||||
|
extern "C" bool media_busy(void) { return true; }
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
#include "hal/phy.h"
|
||||||
|
#include "avclan.h"
|
||||||
|
|
||||||
|
using namespace avclan;
|
||||||
|
using enum detail::Error::Read;
|
||||||
|
using enum detail::Error::Send;
|
||||||
|
|
||||||
|
extern "C" void phy_init() {}
|
||||||
|
|
||||||
|
extern "C" void phy_mute(bool mute) {}
|
||||||
|
|
||||||
|
extern "C" bool phy_is_muted() { return true; }
|
||||||
|
|
||||||
|
extern "C" bool phy_active() { return false; }
|
||||||
|
|
||||||
|
extern "C" void phy_guard_enter() {}
|
||||||
|
|
||||||
|
extern "C" void phy_guard_leave() {}
|
||||||
|
|
||||||
|
extern "C" Read phy_read_startbit() { return BAD_STARTBIT; }
|
||||||
|
|
||||||
|
extern "C" Send phy_send_startbit() { return MUTED; }
|
||||||
|
|
||||||
|
extern "C" Send phy_read_ack() { return MUTED; }
|
||||||
|
|
||||||
|
extern "C" void phy_send_ack() {}
|
||||||
|
|
||||||
|
extern "C" void phy_send_bit(Bit bit) {}
|
||||||
|
|
||||||
|
extern "C" Bit phy_send_bits_u8(const uint8_t *bits, int8_t len) {
|
||||||
|
return Bit::bit_zero;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern "C" Bit phy_send_bits_u16(const uint16_t *bits, int8_t len) {
|
||||||
|
return Bit::bit_zero;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern "C" Bit phy_send_byte(const uint8_t *byte) { return Bit::bit_zero; };
|
||||||
|
|
||||||
|
extern "C" Bit phy_read_bits_u8(uint8_t *bits, uint8_t len) {
|
||||||
|
return Bit::bit_zero;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern "C" Bit phy_read_bits_u16(uint16_t *bits, int8_t len) {
|
||||||
|
return Bit::bit_zero;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern "C" Bit phy_read_byte(uint8_t *byte) { return Bit::bit_zero; };
|
||||||
|
|
||||||
|
#if !defined(NDEBUG) && defined(MEASURE_BUS)
|
||||||
|
// Sample and dump bus bit timing over the serial link (REPL `M`).
|
||||||
|
void phy_measure(void);
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
// -----------------------------------------------------
|
||||||
|
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
|
||||||
|
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
|
||||||
|
// -----------------------------------------------------
|
||||||
|
|
||||||
|
// This header may be included by other board headers as "boards/pimoroni_pico_plus2w_rp2350.h"
|
||||||
|
|
||||||
|
// pico_cmake_set PICO_PLATFORM=rp2350
|
||||||
|
|
||||||
|
#ifndef _BOARDS_PIMORONI_PICO_PLUS2W_RP2350_H
|
||||||
|
#define _BOARDS_PIMORONI_PICO_PLUS2W_RP2350_H
|
||||||
|
|
||||||
|
// For board detection
|
||||||
|
#define PIMORONI_PICO_PLUS2_RP2350
|
||||||
|
#define PIMORONI_PICO_PLUS2W_RP2350
|
||||||
|
|
||||||
|
// --- BOARD SPECIFIC ---
|
||||||
|
#define SPICE_SPI 0
|
||||||
|
#define SPICE_TX_MISO_PIN 32
|
||||||
|
#define SPICE_RX_CS_PIN 33
|
||||||
|
#define SPICE_NETLIGHT_SCK_PIN 34
|
||||||
|
#define SPICE_RESET_MOSI_PIN 35
|
||||||
|
#define SPICE_PWRKEY_BL_PIN 36
|
||||||
|
|
||||||
|
#define PIMORONI_PICO_PLUS2_USER_SW_PIN 45
|
||||||
|
#define PIMORONI_PICO_PLUS2_PSRAM_CS_PIN 47
|
||||||
|
|
||||||
|
// --- UART ---
|
||||||
|
#ifndef PICO_DEFAULT_UART
|
||||||
|
#define PICO_DEFAULT_UART 0
|
||||||
|
#endif
|
||||||
|
#ifndef PICO_DEFAULT_UART_TX_PIN
|
||||||
|
#define PICO_DEFAULT_UART_TX_PIN 0
|
||||||
|
#endif
|
||||||
|
#ifndef PICO_DEFAULT_UART_RX_PIN
|
||||||
|
#define PICO_DEFAULT_UART_RX_PIN 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// --- LED ---
|
||||||
|
#ifndef PICO_DEFAULT_LED_PIN
|
||||||
|
#define PICO_DEFAULT_LED_PIN 25
|
||||||
|
#endif
|
||||||
|
// no PICO_DEFAULT_WS2812_PIN
|
||||||
|
|
||||||
|
// --- I2C ---
|
||||||
|
#ifndef PICO_DEFAULT_I2C
|
||||||
|
#define PICO_DEFAULT_I2C 0
|
||||||
|
#endif
|
||||||
|
#ifndef PICO_DEFAULT_I2C_SDA_PIN
|
||||||
|
#define PICO_DEFAULT_I2C_SDA_PIN 4
|
||||||
|
#endif
|
||||||
|
#ifndef PICO_DEFAULT_I2C_SCL_PIN
|
||||||
|
#define PICO_DEFAULT_I2C_SCL_PIN 5
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// --- SPI ---
|
||||||
|
#ifndef PICO_DEFAULT_SPI
|
||||||
|
#define PICO_DEFAULT_SPI 0
|
||||||
|
#endif
|
||||||
|
#ifndef PICO_DEFAULT_SPI_SCK_PIN
|
||||||
|
#define PICO_DEFAULT_SPI_SCK_PIN SPICE_NETLIGHT_SCK_PIN
|
||||||
|
#endif
|
||||||
|
#ifndef PICO_DEFAULT_SPI_TX_PIN
|
||||||
|
#define PICO_DEFAULT_SPI_TX_PIN SPICE_RESET_MOSI_PIN
|
||||||
|
#endif
|
||||||
|
#ifndef PICO_DEFAULT_SPI_RX_PIN
|
||||||
|
#define PICO_DEFAULT_SPI_RX_PIN SPICE_TX_MISO_PIN
|
||||||
|
#endif
|
||||||
|
#ifndef PICO_DEFAULT_SPI_CSN_PIN
|
||||||
|
#define PICO_DEFAULT_SPI_CSN_PIN SPICE_RX_CS_PIN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// --- FLASH ---
|
||||||
|
|
||||||
|
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
|
||||||
|
|
||||||
|
#ifndef PICO_FLASH_SPI_CLKDIV
|
||||||
|
#define PICO_FLASH_SPI_CLKDIV 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
|
||||||
|
#ifndef PICO_FLASH_SIZE_BYTES
|
||||||
|
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CYW43_WL_GPIO_COUNT
|
||||||
|
#define CYW43_WL_GPIO_COUNT 3
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CYW43_WL_GPIO_LED_PIN
|
||||||
|
#define CYW43_WL_GPIO_LED_PIN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// If CYW43_WL_GPIO_VBUS_PIN is defined then a CYW43 GPIO has to be used to read VBUS.
|
||||||
|
// This can be passed to cyw43_arch_gpio_get to determine if the device is battery powered.
|
||||||
|
// PICO_VBUS_PIN and CYW43_WL_GPIO_VBUS_PIN should not both be defined.
|
||||||
|
|
||||||
|
// no CYW43_WL_GPIO_VBUS_PIN
|
||||||
|
|
||||||
|
// If CYW43_USES_VSYS_PIN is defined then CYW43 uses the VSYS GPIO (defined by PICO_VSYS_PIN) for other purposes.
|
||||||
|
// If this is the case, to use the VSYS GPIO it's necessary to ensure CYW43 is not using it.
|
||||||
|
// This can be achieved by wrapping the use of the VSYS GPIO in cyw43_thread_enter / cyw43_thread_exit.
|
||||||
|
|
||||||
|
// no CYW43_USES_VSYS_PIN
|
||||||
|
|
||||||
|
// The GPIO Pin used to read VBUS to determine if the device is battery powered.
|
||||||
|
#ifndef PICO_VBUS_PIN
|
||||||
|
#define PICO_VBUS_PIN 24
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// The GPIO Pin used to monitor VSYS. Typically you would use this with ADC.
|
||||||
|
// There is an example in adc/read_vsys in pico-examples.
|
||||||
|
#ifndef PICO_VSYS_PIN
|
||||||
|
#define PICO_VSYS_PIN 43
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PICO_RP2350_A2_SUPPORTED
|
||||||
|
#define PICO_RP2350_A2_SUPPORTED 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// PICO_CONFIG: CYW43_PIN_WL_DYNAMIC, flag to indicate if cyw43 SPI pins can be changed at runtime, type=bool, default=false, advanced=true, group=pico_cyw43_driver
|
||||||
|
#ifndef CYW43_PIN_WL_DYNAMIC
|
||||||
|
#define CYW43_PIN_WL_DYNAMIC 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_REG_ON, gpio pin to power up the cyw43 chip, type=int, default=23, advanced=true, group=pico_cyw43_driver
|
||||||
|
#ifndef CYW43_DEFAULT_PIN_WL_REG_ON
|
||||||
|
#define CYW43_DEFAULT_PIN_WL_REG_ON 23u
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_DATA_OUT, gpio pin for spi data out to the cyw43 chip, type=int, default=24, advanced=true, group=pico_cyw43_driver
|
||||||
|
#ifndef CYW43_DEFAULT_PIN_WL_DATA_OUT
|
||||||
|
#define CYW43_DEFAULT_PIN_WL_DATA_OUT 24u
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_DATA_IN, gpio pin for spi data in from the cyw43 chip, type=int, default=24, advanced=true, group=pico_cyw43_driver
|
||||||
|
#ifndef CYW43_DEFAULT_PIN_WL_DATA_IN
|
||||||
|
#define CYW43_DEFAULT_PIN_WL_DATA_IN 24u
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_HOST_WAKE, gpio (irq) pin for the irq line from the cyw43 chip, type=int, default=24, advanced=true, group=pico_cyw43_driver
|
||||||
|
#ifndef CYW43_DEFAULT_PIN_WL_HOST_WAKE
|
||||||
|
#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 24u
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_CLOCK, gpio pin for the spi clock line to the cyw43 chip, type=int, default=29, advanced=true, group=pico_cyw43_driver
|
||||||
|
#ifndef CYW43_DEFAULT_PIN_WL_CLOCK
|
||||||
|
#define CYW43_DEFAULT_PIN_WL_CLOCK 29u
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// PICO_CONFIG: CYW43_DEFAULT_PIN_WL_CS, gpio pin for the spi chip select to the cyw43 chip, type=int, default=25, advanced=true, group=pico_cyw43_driver
|
||||||
|
#ifndef CYW43_DEFAULT_PIN_WL_CS
|
||||||
|
#define CYW43_DEFAULT_PIN_WL_CS 25u
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
#include "hal/stdio.h"
|
||||||
|
#include "pico/stdio_usb.h"
|
||||||
|
|
||||||
|
extern "C" void stdio_init() { stdio_usb_init(); }
|
||||||
|
|
||||||
|
extern "C" bool stdio_write_nonblock(const void *buf, uint8_t len) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user