Software/STM32CubeIDE

STM32CubeIDE BSP Modules

The neuron6_* modules of the Neuro N6 board support package, their main functions and how each is used.

advanced17 min read

The board support package has one module for each part of the board, each a header and a source file named neuron6_<module> at the repository root. Every function returns an int32_t status from neuron6_errno.h unless it reports a value, takes caller-owned buffers rather than allocating, and computes its clock dividers from the frequencies the boot loader left. Functions named *_Callback or *Hook are weak and are defined by the application to receive events.

Error codes

CodeValueMeaning
BSP_ERROR_NONE0Success
BSP_ERROR_NO_INIT-1Module or device not initialised
BSP_ERROR_WRONG_PARAM-2Invalid argument
BSP_ERROR_BUSY-3Busy, or a wait expired
BSP_ERROR_PERIPH_FAILURE-4The peripheral refused its configuration
BSP_ERROR_COMPONENT_FAILURE-5The external device failed
BSP_ERROR_UNKNOWN_FAILURE-6Other failure
BSP_ERROR_UNKNOWN_COMPONENT-7The device did not answer with its identity
BSP_ERROR_BUS_FAILURE-8Bus error
BSP_ERROR_CLOCK_FAILURE-9No usable clock
BSP_ERROR_MSP_FAILURE-10Pin or clock set-up failed
BSP_ERROR_FEATURE_NOT_SUPPORTED-11Not available on this board

BSP_ERROR_BUS_TRANSACTION_FAILURE (-100), BSP_ERROR_BUS_ARBITRATION_LOSS (-101), BSP_ERROR_BUS_ACKNOWLEDGE_FAILURE (-102) and BSP_ERROR_BUS_PROTOCOL_FAILURE (-103) refine a bus error.

Board: neuron6

The board identity, the RGB LED and the USER button.

FunctionPurpose
BSP_GetVersion(), BSP_GetBoardName(), BSP_GetBoardID()BSP version and board identity ("NEURON6", "OHM-N6")
BSP_ISOLATION_Config()Opens the memory firewalls, assigns bus masters and enables the AXI RAM banks; called by every module that needs it
BSP_LED_Init(), BSP_LED_On(), BSP_LED_Off(), BSP_LED_Toggle(), BSP_LED_GetState()LED_RED (PE11), LED_GREEN (PD6) and LED_BLUE (PC1). The package is common anode; the module normalises polarity so that On means lit
BSP_PB_Init(BUTTON_USER, mode), BSP_PB_GetState()USER button on PG8, read as BUTTON_PRESSED while held. BUTTON_MODE_GPIO polls it; BUTTON_MODE_EXTI delivers presses to BSP_PB_Callback() from BSP_PB_IRQHandler() on EXTI8

Console: neuron6_com

The board has no debug UART; its console is a USB CDC port on the USB-C connector, carried by TinyUSB with the configuration in Utilities/usb/. The module retargets printf to it and handles the 1200 baud touch, so a board running the console can always be sent to its boot loader.

FunctionPurpose
BSP_COM_Init(), BSP_COM_DeInit()Start or stop the USB device stack and the console, once per session
BSP_COM_Task()Services the USB stack; called regularly from the main loop, or by the USB task under FreeRTOS
BSP_COM_IsConnected()Whether a host has opened the port
BSP_COM_Write(), BSP_COM_Read(), BSP_COM_Printf(), BSP_COM_Flush()Output and input. Output is dropped rather than blocked when no host has the port open
BSP_COM_RebootToBootloader()Sets the force-DFU flag and resets into the boot loader
BSP_COM_IRQHandler()Called from USB1_OTG_HS_IRQHandler()

With BSP_USB_UVC set to 1 in neuron6_conf.h the board enumerates as a USB video camera beside the console, and the application supplies the frames.

Watchdog: neuron6_wdg

FunctionPurpose
BSP_WDG_Init(timeout_ms)Starts the independent watchdog with a timeout in milliseconds, from BSP_WDG_TIMEOUT_MIN_MS to BSP_WDG_TIMEOUT_MAX_MS
BSP_WDG_InitEWI(timeout_ms, warning_ms)The same, with an early warning interrupt warning_ms before the reset, delivered to BSP_WDG_EWI_Callback()
BSP_WDG_Refresh()Reloads the counter

The examples arm the watchdog at 4000 ms with a 300 ms early warning, and aim the warning at the boot loader.

Buses: neuron6_bus

BusPinsUse
I2C1PH9 (SCL), PE6 (SDA), 40-pin connectorOn-board sensor bus: inertial unit, magnetometer, camera control and module sensors. Runs at about 295 kHz, below the thermal camera's command interface limit
I2C2Header SCL (PD14), SDA (PD15)Expansion. Timing computed at run time
SPI2Header SCK (PF2), MO (PD7), MI (PD11)Expansion. Clock, mode and bit order settable
FunctionPurpose
BSP_I2C1_Init(), BSP_I2C2_Init() and their DeInitBring a bus up or release it. Reference counted, so several modules share a bus
BSP_I2Cx_WriteReg(), BSP_I2Cx_ReadReg(), BSP_I2Cx_WriteReg16(), BSP_I2Cx_ReadReg16()Register access with 8-bit or 16-bit register addresses. The signatures fit ST component *_IO_t contexts
BSP_I2Cx_Send(), BSP_I2Cx_Recv(), BSP_I2Cx_IsReady()Raw transfers and device probing
BSP_SPI2_Init(), BSP_SPI2_SetConfig(), BSP_SPI2_GetConfig(), BSP_SPI2_GetClockFreq()SPI set-up; the divider is recomputed from the live kernel clock on every change
BSP_SPI2_Send(), BSP_SPI2_Recv(), BSP_SPI2_SendRecv()Transfers
BSP_I2C1_Lock(), BSP_I2C1_Unlock() and the I2C2 and SPI2 equivalentsWeak lock hooks, recursive mutexes under FreeRTOS

In neuron6_conf.h, BUS_I2C1_TIMING_OVERRIDE replaces the sensor bus timing, BUS_I2C2_FREQUENCY sets the expansion I2C clock (default 100 kHz) and BUS_SPI2_FREQUENCY the starting SPI clock (default 4 MHz).

Header pins: neuron6_io

neuron6_io holds one table describing the header, which neuron6_adc and neuron6_pwm also read. Pins are named BSP_IO_PIN_D0, D1, D5, D6, D9 to D13, A0 to A5, SDA, SCL, MOSI, MISO, SCK, LED_RED, LED_GREEN, LED_BLUE and BUTTON. Header positions that are not routed (D2, D3, D4, D7, D8) are refused, and no pin the camera, memory or radio paths use has a row.

FunctionPurpose
BSP_IO_ConfigPin(pin, mode)BSP_IO_MODE_INPUT, INPUT_PU, INPUT_PD, OUTPUT_PP, OUTPUT_OD or ANALOG
BSP_IO_WritePin(), BSP_IO_ReadPin(), BSP_IO_TogglePin()Digital I/O
BSP_IO_GetPinInfo(), BSP_IO_HasPwm(), BSP_IO_HasAdc()The pin's port, ADC route and timer route
BSP_IO_AttachInterrupt(pin, trigger, callback), BSP_IO_DetachInterrupt()EXTI on BSP_IO_TRIGGER_RISING, FALLING or BOTH, dispatched by BSP_IO_IRQHandler()
BSP_IO_ReadPulse()Width of a pulse in microseconds, with a timeout
BSP_IO_ShiftOut(), BSP_IO_ShiftIn()Bit-banged shift register, BSP_IO_MSB_FIRST or BSP_IO_LSB_FIRST

Pins with the same number on different ports share an EXTI line, so only one of them has an interrupt attached at a time.

Analogue input: neuron6_adc

ADC1 and ADC2 run independently and convert the header inputs A0 to A5, the analogue supply, the battery and the core supply. The inputs are referenced to the 1.8 V analogue supply, and voltages are scaled against the measured supply.

FunctionPurpose
BSP_ADC_Init()Brings up both converters; optional, since every read brings its converter up
BSP_ADC_SetResolution(), BSP_ADC_GetResolution()BSP_ADC_RESOLUTION_6B, 8B, 10B or 12B
BSP_ADC_ReadChannel(pin, &counts), BSP_ADC_ReadVoltage(pin, &mV)A header input as counts or millivolts
BSP_ADC_GetVdda(), BSP_ADC_IsVddaMeasured()The analogue supply. BSP_ADC_NOMINAL_VDDA_MV supplies it when the part carries no usable factory calibration
BSP_ADC_ReadVBat(), BSP_ADC_ReadVddCore()Battery and core supply in millivolts. The battery reaches the converter through a divide-by-four

PWM and tone: neuron6_pwm

Five pins reach a timer: D5 (TIM1), A4 (TIM2) and the three LED channels (TIM1, TIM15, TIM17). The tone generator produces a square wave on any routed pin from TIM3. Timer clocks are measured against the cycle counter.

FunctionPurpose
BSP_PWM_Init()Prepares the module
BSP_PWM_SetFrequency(), BSP_PWM_GetFrequency()1 Hz to 1 MHz, default 1 kHz
BSP_PWM_SetResolution(), BSP_PWM_GetResolution()Duty resolution of 4 to 16 bits, default 8
BSP_PWM_Start(pin, duty), BSP_PWM_Stop(pin)Starts or stops modulation on a pin
BSP_PWM_GetTimerClockFreq()The measured timer clock
BSP_TONE_Start(pin, frequency, duration_ms), BSP_TONE_Stop(), BSP_TONE_IsActive()Square wave, serviced by BSP_TONE_IRQHandler()

The LEDs are active low, so a larger duty makes an LED dimmer.

Motion sensors: neuron6_motion_sensor

ST's motion sensor API over two instances: MOTION_SENSOR_LSM6DSL_0, the accelerometer and gyroscope, and MOTION_SENSOR_MMC5603NJ_0, the magnetometer. Functions are a bit mask of MOTION_ACCELERO, MOTION_GYRO and MOTION_MAGNETO. Readings are in milli-g, millidegrees per second and milligauss.

FunctionPurpose
BSP_MOTION_SENSOR_Init(instance, functions), BSP_MOTION_SENSOR_Enable(), BSP_MOTION_SENSOR_Disable()Bring a sensor up and enable its functions
BSP_MOTION_SENSOR_GetAxes(), BSP_MOTION_SENSOR_GetAxesRaw()Scaled or raw readings
BSP_MOTION_SENSOR_SetOutputDataRate(), BSP_MOTION_SENSOR_SetFullScale() and their getters, BSP_MOTION_SENSOR_GetSensitivity()Rate and range
BSP_MOTION_SENSOR_GetTemperature()Die temperature of either sensor
BSP_MOTION_SENSOR_GetDataReady(), BSP_MOTION_SENSOR_Degauss()Magnetometer data ready flag and degauss
c
BSP_MOTION_SENSOR_Init(MOTION_SENSOR_LSM6DSL_0, MOTION_ACCELERO | MOTION_GYRO);
BSP_MOTION_SENSOR_Enable(MOTION_SENSOR_LSM6DSL_0, MOTION_ACCELERO);
BSP_MOTION_SENSOR_GetAxes(MOTION_SENSOR_LSM6DSL_0, MOTION_ACCELERO, &acc);   /* mg */

Ranging sensor: neuron6_ranging_sensor

ST's ranging sensor API over the VL53L1CB time of flight sensor on the OV5640, TFT and STCam carriers, one instance, RANGING_SENSOR_VL53L1CB_0. The part computes each range itself, in long distance mode with a 100 ms timing budget.

FunctionPurpose
BSP_RANGING_SENSOR_Init(), BSP_RANGING_SENSOR_ReadID()Bring the sensor up
BSP_RANGING_SENSOR_Start(instance, mode), BSP_RANGING_SENSOR_Stop()RANGING_SENSOR_MODE_BLOCKING_CONTINUOUS, BLOCKING_ONESHOT, ASYNC_CONTINUOUS or ASYNC_ONESHOT
BSP_RANGING_SENSOR_IsMeasurementReady(), BSP_RANGING_SENSOR_GetDistance()A distance in millimetres with its status; status 0 is a valid range
BSP_RANGING_SENSOR_ConfigROI()Region of interest
BSP_RANGING_SENSOR_StartGrid(), StepGrid(), GetGrid(), StopGrid()A 4 x 4 grid of zones, swept one zone at a time

Thermal camera: neuron6_thermal

The FLIR Lepton 3.1R on the Thermal carrier: its command interface on I2C1 at address 0x2A, and 160 x 120 radiometric video over SPI1 with its own GPDMA channel. Power-down is PD3, reset PD9 and chip select PF4.

FunctionPurpose
BSP_THERMAL_PowerOn(), BSP_THERMAL_PowerOff()Power-cycles the camera and releases it from reset, or holds it in power-down
BSP_THERMAL_Init(), BSP_THERMAL_DeInit()Powers the camera if needed and waits for it to finish booting. Nothing else may use the sensor bus from power-up until this returns
BSP_THERMAL_Ping(), GetSerialNumber(), GetUptime(), GetFpaTemperature(), GetAuxTemperature()Commands. Temperatures are in hundredths of a kelvin
BSP_THERMAL_GetAgcEnabled(), SetAgcEnabled(), RunFfc()Automatic gain and flat field correction
BSP_THERMAL_ReadRegister(), WriteRegister(), GetAttribute(), SetAttribute(), RunCommand()Raw command interface
BSP_THERMAL_VideoStart(instance, ring, size), VideoStop(), VideoResync()Starts video into a caller-owned ring of up to 64288 bytes, 32-byte aligned and a multiple of 1312
BSP_THERMAL_GetFrame(instance, frame, timeout_ms)Assembles the next 160 x 120 frame of 16-bit pixels
BSP_THERMAL_SetFlip180(), BSP_THERMAL_GetHealth()Turns frames half a turn, for the carrier's mounting; stream counters

The command interface is used only before video starts. With automatic gain off, each pixel is a temperature in hundredths of a kelvin. With BSP_THERMAL_AUTO_RESYNC set, BSP_THERMAL_GetFrame() restarts a stalled stream by itself. The DMA descriptor is placed in the non-cacheable section BSP_THERMAL_DMA_NODE_SECTION names.

Camera: neuron6_camera

The camera module drives a sensor over two-lane MIPI CSI-2 into the DCMIPP's three pipes.

PipeConstantOutput
Pipe 0BSP_CAMERA_PIPE_DUMPFull frame, RGB565 from a colour sensor or BSP_CAMERA_PIPE_PF_RAW8 from a raw one
Pipe 1BSP_CAMERA_PIPE_MAINFull frame YUV422, or YUV420 semi-planar or full-planar, through the DCMIPP's processing stages
Pipe 2BSP_CAMERA_PIPE_AUXRGB888 with crop, decimation and downsize

The sensor is registered through a driver interface. The OV5640 is the default; BSP_CAMERA_VD66GY_Register() and BSP_CAMERA_VD65G4_Register() select the global shutter sensors. BSP_CAMERA_SetCarrier() selects the receiver's lane mapping, which the carrier decides: BSP_CAMERA_CARRIER_STANDARD or BSP_CAMERA_CARRIER_INVERTED. The OV5640 on the TFT carriers and the VD66GY on the Thermal carrier use INVERTED. A wrong setting gives no error and no frames. BSP_CAMERA_DEFAULT_CARRIER in neuron6_conf.h sets the mapping used when BSP_CAMERA_SetCarrier() is not called.

FunctionPurpose
BSP_CAMERA_SetCarrier(), BSP_CAMERA_RegisterSensor()Lane mapping and sensor, before Init
BSP_CAMERA_Init(0, resolution, format), BSP_CAMERA_DeInit()Brings the sensor and link up at a resolution and sensor format: BSP_CAMERA_PF_RGB565 for the OV5640, BSP_CAMERA_PF_RAW8 for the global shutter sensors
BSP_CAMERA_ConfigPipe(0, pipe, &config)A pipe's output format, size and crop
BSP_CAMERA_Start(0, pipe, buffer, mode), BSP_CAMERA_Stop()BSP_CAMERA_MODE_CONTINUOUS or BSP_CAMERA_MODE_SNAPSHOT
BSP_CAMERA_DoubleBufferStart(), SemiPlanarStart(), FullPlanarStart() and their double-buffer formsAlternating buffers and YUV420 on the main pipe
BSP_CAMERA_Suspend(), Resume(), SuspendSensor(), ResumeSensor(), HaltCapture()Pause a pipe or the sensor
BSP_CAMERA_GetCapabilities(), GetFrameSize(), SetResolution(), GetPixelFormat()Queries and mode change
BSP_CAMERA_SetMirrorFlip(), SetBrightness(), SetSaturation(), SetContrast(), SetHueDegree(), SetLightMode(), SetColorEffect(), SetZoom(), EnableNightMode()The sensor's own picture controls, where the sensor has them
BSP_CAMERA_ConfigLineBuffer()Address wrapping into a band and the line event that paces the video encoder
BSP_CAMERA_SetIspDemosaicing(), SetIspBlackLevel(), SetIspGain(), SetIspColorConversion(), SetIspGamma()The main pipe's processing stages, for a raw sensor
BSP_CAMERA_FrameEventCallback(), VsyncEventCallback(), LineEventCallback(), ErrorCallback()Per-pipe events
BSP_CAMERA_DCMIPP_IRQHandler(), BSP_CAMERA_CSI_IRQHandler()Interrupt entry points

OV5640 resolutions and frame rate ceilings:

ConstantPixelsMaximum frame rate
BSP_CAMERA_R320x240320x24060
BSP_CAMERA_R640x480640x48060
BSP_CAMERA_R800x480800x48060
BSP_CAMERA_R1024x7681024x76830
BSP_CAMERA_R1280x7201280x72060
BSP_CAMERA_R1920x10801920x108030
BSP_CAMERA_R2592x19442592x194415

The carriers tie the OV5640's reset and power-down pins off, so BSP_CAMERA_Init() resets the sensor through its registers.

c
BSP_CAMERA_SetCarrier(BSP_CAMERA_CARRIER_INVERTED);              /* TFT carrier */
BSP_CAMERA_Init(0, BSP_CAMERA_R800x480, BSP_CAMERA_PF_RGB565);
pipe.PixelFormat = BSP_CAMERA_PIPE_PF_RGB565;
pipe.Width = 800;
pipe.Height = 480;
BSP_CAMERA_ConfigPipe(0, BSP_CAMERA_PIPE_DUMP, &pipe);
BSP_CAMERA_Start(0, BSP_CAMERA_PIPE_DUMP, frameBuffer, BSP_CAMERA_MODE_CONTINUOUS);

VD66GY: neuron6_camera_vd66gy

The ST VD66GY global shutter sensor sends raw 8-bit data at 804 Mbps per lane in every mode. The main pipe reconstructs colour before its conversion and shares its output with the auxiliary pipe; the dump pipe carries the raw data. The sensor runs its own exposure loop from the first frame; white balance and colour correction are set through BSP_CAMERA_SetIspGain() and BSP_CAMERA_SetIspColorConversion().

FunctionPurpose
BSP_CAMERA_VD66GY_Register()Registers the sensor, before BSP_CAMERA_Init()
BSP_CAMERA_VD66GY_SetFrameRate(fps)A rate below the mode's ceiling, before Init; 0 runs at the ceiling
BSP_CAMERA_VD66GY_GetBayerOrder()The colour filter order the sensor reports, after Init
BSP_CAMERA_VD66GY_SetBrightness(level)Brightness, 0 to 100, that the sensor's exposure loop aims at
BSP_CAMERA_VD66GY_GetContext()The driver context, for manual exposure, gain and the other controls the module does not wrap
ConstantPixelsMaximum frame rate
BSP_CAMERA_VD66GY_R320x240320x24088
BSP_CAMERA_VD66GY_R640x480, R480x640640x480, portrait 480x64088
BSP_CAMERA_VD66GY_R1024x768, R768x10241024x768, portrait 768x102460
BSP_CAMERA_VD66GY_R720x1280720x128060
BSP_CAMERA_VD66GY_R1024x12801024x128045
BSP_CAMERA_VD66GY_R1120x7201120x72060
BSP_CAMERA_VD66GY_R1120x13641120x1364, the whole array45
c
BSP_CAMERA_VD66GY_Register();
BSP_CAMERA_SetCarrier(BSP_CAMERA_CARRIER_INVERTED);   /* Thermal carrier only */
BSP_CAMERA_Init(0, BSP_CAMERA_VD66GY_R1024x768, BSP_CAMERA_PF_RAW8);

The sensor starts from its power-up state and the carriers give it no reset line; the board's reset reaches it, so a reset or an upload with power applied starts it again. Components/vd6g/vd6g.c is compiled with NDEBUG.

VD65G4: neuron6_camera_vd65g4

The ST VD65G4 colour global shutter sensor registers through the same interface with BSP_CAMERA_VD65G4_Register() and drives a single data lane. Its modes are BSP_CAMERA_VD65G4_R320x240, R640x480, R800x600 and R804x704 (the whole array), each at up to 60 frames per second. Its bus address, oscillator, lane rate and lane swaps are BSP_CAMERA_VD65G4_* constants in neuron6_conf.h. BSP_CAMERA_VD65G4_GetBayerOrder(), BSP_CAMERA_VD65G4_SetBrightness() and BSP_CAMERA_VD65G4_GetContext() correspond to the VD66GY functions of the same names. The driver is Components/vd55g1.

Video encoder: neuron6_venc

The STM32N6's hardware JPEG encoder, fed directly from the camera. The camera writes into a band in RAM by address wrapping, and the DCMIPP's line event is connected in silicon to the encoder's ready input, so the encoder codes a few macroblock rows behind the sensor without the processor touching a pixel. Every camera mode encodes at the sensor's rate.

FunctionPurpose
BSP_VENC_EnablePeripheral()Clocks the encoder and admits it to the isolation scheme, while the camera pipe is configured and before it starts
BSP_VENC_GetBandGeometry(width, height, &band)Band size, wrap and event line counts, which are passed to BSP_CAMERA_ConfigLineBuffer()
BSP_VENC_Init(0, &config), BSP_VENC_DeInit()Band, quality (BSP_VENC_QUALITY_MIN 0 to BSP_VENC_QUALITY_MAX 9) and the SourceStart function that starts the camera once the encoder is armed
BSP_VENC_EncodeBand(0, out, size, &bytes)Encodes the next frame from the camera into a JFIF buffer
BSP_VENC_EncodeFrame()Encodes a frame already in memory
BSP_VENC_Resync()Re-arms the encoder after it and the camera lose step
BSP_VENC_Quiesce()Brings the encoder to a safe stop before a reset, from a console command, a watchdog warning or a fault handler
BSP_VENC_GetStatistics(), BSP_VENC_LastFrameTorn()Frame counters, and whether the camera overran the band
BSP_VENC_ReadPointerHook()Weak hook called repeatedly with the encoder's progress during a bare-metal encode, while the encoder waits on the camera; the bare-metal streaming examples service USB from it. Under FreeRTOS the encode waits for the encoder's interrupt and the hook is not called
BSP_VENC_WaitBeginHook()Weak hook called once per encode when the wait on the camera begins, where an RTOS application lowers the encoding task's priority

Output buffers are 16-byte aligned and in memory the processor does not cache. The encoder needs BSP_VENC_HEAP_BYTES (72 KB) of heap. Examples/Camera_JpegStream_USB shows the complete sequence.

Display: neuron6_lcd

The 800 x 480 parallel RGB panel of the TFT carriers on the LTDC.

FunctionPurpose
BSP_LCD_Init(0, 800, 480), BSP_LCD_DeInit()Brings the controller up
BSP_LCD_ConfigLayer(0, layer, &config)Window, pixel format (BSP_LCD_PIXEL_FORMAT_RGB565, ARGB4444 or ARGB8888), frame buffer address and constant alpha for BSP_LCD_LAYER_0 or BSP_LCD_LAYER_1
BSP_LCD_SetLayerAddressVBlank(), BSP_LCD_SetLayerAddress(), BSP_LCD_IsReloadPending(), BSP_LCD_Reload()Buffer flips at the vertical blank, or at once
BSP_LCD_SetLayerVisible(), SetTransparency(), SetActiveLayer(), SetLayerWindow()Layer control
BSP_LCD_SetColorKeying(), ResetColorKeying()Per-layer colour key
BSP_LCD_DisplayOn(), DisplayOff(), GetXSize(), GetYSize()Panel control
BSP_LCD_SetRefreshRate(), GetRefreshRate()30 to 60 Hz, default 60, computed from the PLL4 readback
BSP_LCD_GetStatus()Underrun and transfer error counters
BSP_LCD_WritePixel(), ReadPixel(), FillRect(), FillRGBRect(), DrawHLine(), DrawVLine(), DrawBitmap()Drawing by the processor, with cache maintenance

The application supplies every frame buffer, 16-byte aligned; a full RGB565 frame is 768 KB and sits in PSRAM (the .ext_psram section of the linker script). The capture pipe can write RGB565 directly into the frame buffer the controller scans out.

Audio: neuron6_audio

The MAX98357A speaker amplifier on SAI1 block B, and the MP34DT05-A PDM microphone on MDF1. Both use caller-owned buffers with half and complete callbacks.

FunctionPurpose
BSP_AUDIO_OUT_Init(0, &init), BSP_AUDIO_IN_Init(0, &init)BSP_AUDIO_Init_t gives the device, sample rate, bits per sample, channel count and volume
BSP_AUDIO_OUT_Play(0, buffer, bytes), BSP_AUDIO_IN_Record(0, buffer, bytes)Circular playback or recording
Pause(), Resume(), Stop()Transport control for either direction
BSP_AUDIO_OUT_Mute(), UnMute(), IsMute()The amplifier's shutdown pin
SetSampleRate(), GetSampleRate()Requested rate and the rate the hardware runs at
BSP_AUDIO_OUT_HalfTransfer_CallBack(), TransferComplete_CallBack(), Error_CallBack() and the IN equivalentsBuffer events
BSP_AUDIO_OUT_IRQHandler(), BSP_AUDIO_IN_IRQHandler()GPDMA interrupt entry points

A requested rate is accepted only within one per cent of a rate the clock tree can produce, and within the parts' ranges: 8 to 96 kHz for the amplifier and about 9.4 to 50.8 kHz for the microphone. A rate of 0, BSP_AUDIO_FREQUENCY_NATIVE, selects the native rates, 48828 Hz out and 32552 Hz in. GetSampleRate() reports the rate in use. The board has no codec, so volume control returns BSP_ERROR_FEATURE_NOT_SUPPORTED.

NPU: neuron6_npu

Prepares the Neural-ART accelerator's environment: its RAM banks, cache, interrupts and isolation. The runtime that runs a network is ST Edge AI's, carried in Middlewares/ST/AI_Runtime (see Middleware).

FunctionPurpose
BSP_NPU_Init(), BSP_NPU_DeInit()Brings the NPU's clocks, RAM, cache and interrupts up
BSP_NPU_GetRamInfo(&base, &sizeKB)The NPU RAM region

Wi-Fi: neuron6_wifi

Power and the SDIO transport of the u-blox MAYA-W476 module on the -W carriers. The module stops at the transport; the Wi-Fi stack in Middlewares/NeuroN6/MayaW476/ drives SDMMC1 itself, so an application uses one or the other.

FunctionPurpose
BSP_WIFI_ModulePowerOn(), ModulePowerOff(), ModuleIsPowered()Module power sequence
BSP_WIFI_IsFirmwarePresent(), BSP_WIFI_GetFirmware()Whether anything is programmed at the IW610 firmware address, 0x91E00000, and the region's address and size
BSP_WIFI_Init(), BSP_WIFI_DeInit()Card enumeration on SDMMC1
BSP_WIFI_ReadDirect(), WriteDirect(), ReadExtended(), WriteExtended()CMD52 and CMD53 transfers
BSP_WIFI_SetBlockSize(), EnableFunction(), EnableFunctionInterrupt(), RearmCardInterrupt()SDIO function control
BSP_WIFI_SetWake(), GetWakeOut()The host-to-module and module-to-host wake lines (PG0, PB7)
BSP_WIFI_CardInterruptCallback(), BSP_WIFI_WakeCallback()Events

The module runs the SDIO bus to the radio at 8.163 MHz once the card is enumerated, set by BSP_WIFI_SDIO_TRANSFER_DIV in neuron6_conf.h, which defaults to 0x07.

BLE: neuron6_bt

The BLE host controller interface (HCI) to the MAYA-W476 over USART6, delivering whole packets. The link starts at 115200 baud. A BLE host stack, Apache NimBLE, is carried separately in Middlewares/NeuroN6/BleHost (see Middleware). The radio firmware is loaded over SDIO first, with MayaW476_RadioStart().

FunctionPurpose
BSP_BT_Init(), BSP_BT_DeInit()Opens the HCI link, with RTS and CTS flow control when USE_BSP_BT_FLOW_CONTROL is set
BSP_BT_SetBaudRate(), GetBaudRate()Link speed. Speeds above the starting one need flow control
BSP_BT_Send(), BSP_BT_Receive(), GetAvailable(), Flush()Packets
BSP_BT_Command(opcode, params, length, ...)Sends an HCI command and waits for its Command Complete
BSP_BT_ScanStart(), ScanNext(), ScanStop()LE scanning
BSP_BT_AdvertiseStart(), AdvertiseStop()LE advertising
BSP_BT_GetInfo(), GetHealth()Controller identity and link counters
BSP_BT_IRQHandler(), BSP_BT_RxCallback(), BSP_BT_ErrorCallback()Interrupt and events

No command can set BLE transmit power above 8 dBm, the ceiling the Wi-Fi side has too. The radio's own default, 7 dBm, is set by its factory calibration. NXP's LE power command (0xFC87) has its level and limit capped at 8 dBm and its front-end loss flag cleared, and LE Transmitter Test v4 (0x207B) has its power capped at 8 dBm. Any other vendor command (OGF 0x3F) is refused before a byte of it is sent, and BSP_BT_Send() returns BSP_ERROR_FEATURE_NOT_SUPPORTED.

FreeRTOS glue: neuron6_rtos

Compiled only with BSP_USE_FREERTOS. It turns the weak lock hooks into recursive mutexes, makes HAL_Delay yield, locks newlib's allocator, and provides the USB task.

FunctionPurpose
BSP_RTOS_StartUsbTask(stackWords, priority)Starts the task that services TinyUSB, woken by its interrupt; 0 selects the defaults
BSP_RTOS_FatalHook()Weak hook reached on a stack overflow or failed configASSERT

Component drivers

DirectoryDevice
Components/ov5640/OmniVision OV5640 image sensor, ST driver with the board's mode tables
Components/vd6g/ST VD66GY image sensor
Components/vd55g1/ST VD55G1 driver, used for the VD65G4
Components/venc/Verisilicon VC8000NanoE JPEG encoder and ST's wrapper layer
Components/lsm6dsl/LSM6DSL inertial unit
Components/mmc5603nj/MMC5603NJ magnetometer
Components/lepton/FLIR Lepton command protocol and video stream parser
Components/vl53l1cb/VL53L1CB time of flight sensor