54 lines
2.3 KiB
C
54 lines
2.3 KiB
C
/******************************************************************************
|
|
* File: MCU_PIO_cfg.c
|
|
* Component: MCU_PIO
|
|
* Description: Configuration array definition for the PIO driver.
|
|
* Wires each PIO instance to its compiled program and
|
|
* program-specific init function. The WS2812 init wrapper
|
|
* adapts the auto-generated ws2812_program_init() signature
|
|
* to match the generic MCU_PIO_tpfProgramInit callback type.
|
|
*
|
|
* Layer: MCU (hardware abstraction) - configuration
|
|
*****************************************************************************/
|
|
|
|
#include "MCU_PIO.h"
|
|
#include "MCU_PIO_cfg.h"
|
|
|
|
/* Auto-generated header from ws2812.pio — provides ws2812_program struct
|
|
* and ws2812_program_init() helper. Generated at build time by
|
|
* pico_generate_pio_header() in mcu_config.cmake. */
|
|
#include "ws2812.pio.h"
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
/* WS2812 INIT WRAPPER */
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
/**
|
|
* @brief Adapts ws2812_program_init() to the MCU_PIO_tpfProgramInit
|
|
* signature by hardcoding the WS2812 bit frequency (800 kHz).
|
|
*
|
|
* The auto-generated ws2812_program_init() takes an extra `float freq`
|
|
* parameter that is not part of the generic callback type. This wrapper
|
|
* fills it in so the generic driver can call it without knowing about
|
|
* WS2812 specifics.
|
|
*/
|
|
static void vWs2812Init(PIO pstrPio, u8 u8Sm, u8 u8Pin, u32 u32Offset)
|
|
{
|
|
ws2812_program_init(pstrPio, (u32)u8Sm, (u32)u32Offset, (u32)u8Pin, 800000.0f);
|
|
}
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
/* CONFIGURATION ARRAY */
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
const MCU_PIO_tstrConfig MCU_PIO_astrConfig[MCU_PIO_NUM_INSTANCES] =
|
|
{
|
|
[MCU_PIO_INSTANCE_WS2812] =
|
|
{
|
|
.pstrPio = pio0, /* use PIO block 0 */
|
|
.u8Sm = 0U, /* state machine 0 within pio0 */
|
|
.u8Pin = MCU_PIO_WS2812_PIN,
|
|
.pstrProgram = &ws2812_program,
|
|
.pfProgramInit = vWs2812Init,
|
|
},
|
|
};
|