rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
iomcu_tone.c File Reference

The TONE page and the phase tap's capture behind it; see iomcu.h for the other files. More...

#include <string.h>
#include "iomcu.h"
#include "pd_uart.h"
#include "tone_cap.h"
#include "tone_core1.h"

Functions

uint64_t tone_taken (void)
 Returns the pins the phase tap may not take now.
static void tone_order (void)
 Core 1's order from the page, running when the capture does.
static bool tone_rewire_as (bool keep_ring)
 Makes the capture agree with the TONE page: stopped, then started on the page's pin.
bool tone_rewire (void)
 Makes the phase tap's capture agree with the TONE page's pin.
void tone_read (void *ctx, uint8_t off, uint8_t n, uint16_t *out)
 Reads the TONE page.
uint8_t tone_write (void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
 Writes the TONE page.

Variables

static bool s_tone_busy
static uint64_t s_tone_was_us

Detailed Description

The TONE page and the phase tap's capture behind it; see iomcu.h for the other files.

SPDX-License-Identifier: MIT

Function Documentation

◆ tone_read()

void tone_read ( void * ctx,
uint8_t off,
uint8_t n,
uint16_t * out )

Reads the TONE page.

Parameters
ctxUnused.
offFirst register to read.
nNumber of registers to read.
outReceives the n register values.

◆ tone_rewire()

bool tone_rewire ( void )

Makes the phase tap's capture agree with the TONE page's pin.

Returns
True when the capture agrees with the page. False when the wiring could not take the pin, or core 1 was still in a pass.

◆ tone_rewire_as()

bool tone_rewire_as ( bool keep_ring)
static

Makes the capture agree with the TONE page: stopped, then started on the page's pin.

Parameters
keep_ringTrue to recapture the ring with the elapsed time since the start saved by the earlier rewire (tone_page_recapture()); false to start a new capture (tone_page_capture()).
Returns
False when the tap is enabled and the wiring could not take its pin (no PIO state machine, no DMA channel), or core 1 was still in a pass and the old capture runs on. True otherwise.

◆ tone_taken()

uint64_t tone_taken ( void )

Returns the pins the phase tap may not take now.

Returns
One bit per GPIO: the supply's pins, the programming ports' pins and the sensor bus's pins, including those core 1 has not let go of yet.

◆ tone_write()

uint8_t tone_write ( void * ctx,
uint8_t off,
uint8_t n,
const uint16_t * in )

Writes the TONE page.

Parameters
ctxUnused.
offFirst register to write.
nNumber of registers to write.
inThe n register values to write.
Returns
0 to accept, or a link_nack_t to refuse.