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

Core 1's half of the phase tap. More...

#include "tone_core1.h"
#include <string.h>
#include "hardware/sync.h"
#include "pico/stdlib.h"
#include "tone_cap.h"

Data Structures

struct  q_entry_t
 One beep queued for core 0, with the generations it was made under. More...

Functions

void tone_core1_init (void)
 Claim the spin lock; before core 1 starts.
void tone_core1_order (const tone_cmd_t *cmd, uint64_t t0_us)
 A new order for core 1, taken at its next tick.
bool tone_core1_quiesce (void)
 Core 0: wait until core 1 has finished a pass under the latest order.
static void push (const tone_rec_t *r, uint16_t gen, uint16_t cap_gen)
 Pushes one beep onto the queue to core 0. A beep that finds the queue full is counted in s_dropped and dropped.
static void pass (void)
 One pass under the order taken.
void tone_core1_step (void)
 Core 1's pass, once a tick.
void tone_core1_sync (tone_page_t *page)
 Core 0: take what core 1 has handed over into page: the beeps in the queue and the newest status.

Variables

static spin_lock_t * s_lock
static tone_cmd_t s_order
static uint64_t s_order_t0_us
static uint32_t s_order_seq
static tone_status_t s_status
static volatile uint32_t s_status_seq
static volatile uint32_t s_ack_seq
static volatile bool s_live
static q_entry_t s_q [TONE_Q_LEN]
static volatile uint32_t s_q_head
static volatile uint32_t s_q_tail
static volatile uint32_t s_dropped
static tone_svc_t s_svc
 Static: the service holds the detector, 1,100 bytes or so, and core 1's stack is small.
static tone_cmd_t s_cmd
static uint64_t s_cmd_t0_us
static uint32_t s_cmd_seq
static tone_status_t s_snap
static tone_rec_t s_rec [TONE_SVC_BEEPS]
static bool s_started
static uint32_t s_taken_seq
static uint32_t s_dropped_seen

Detailed Description

Core 1's half of the phase tap.

See tone_core1.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ push()

void push ( const tone_rec_t * r,
uint16_t gen,
uint16_t cap_gen )
static

Pushes one beep onto the queue to core 0. A beep that finds the queue full is counted in s_dropped and dropped.

Parameters
rThe beep.
genSet-up generation the beep was made under.
cap_genCapture generation the beep was made under.

◆ tone_core1_order()

void tone_core1_order ( const tone_cmd_t * cmd,
uint64_t t0_us )

A new order for core 1, taken at its next tick.

t0_us is the microsecond timer when the capture's counter began.

Parameters
cmdThe order to post.
t0_usThe microsecond timer when the capture's counter began.

◆ tone_core1_quiesce()

bool tone_core1_quiesce ( void )

Core 0: wait until core 1 has finished a pass under the latest order.

Bounded by TONE_CORE1_WAIT_US; returns at once when core 1 has not taken an order yet (at boot: the first it takes is the latest). False when the bound passed without the acknowledgement: core 1 may still be in a pass that reads the capture (a long pass, or parked for a flash write), and nothing may be taken down.

Returns
True when core 1 acknowledged the order or has not taken one. False when the bound passed without the acknowledgement.

◆ tone_core1_sync()

void tone_core1_sync ( tone_page_t * page)

Core 0: take what core 1 has handed over into page: the beeps in the queue and the newest status.

Cheap when nothing is new.

Parameters
pageThe TONE page the beeps and the status are taken into.