|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The TONE link page. More...
Macros | |
| #define | SEQ_PERIOD 65535u |
| The beep numbers: 1 to 65535, then 1 again. | |
Functions | |
| void | tone_page_defaults (uint16_t *cfg) |
The set-up as a page starts, into cfg (LINK_TN_CONFIG_COUNT registers): the tap off, GP22, 400 to 6500Hz, 8%, 3ms, 3 periods. | |
| void | tone_page_init (tone_page_t *p) |
| Set the page to its start: the defaults, and the first beep number 1. | |
| bool | tone_page_enabled (const tone_page_t *p) |
| Whether ENABLE bit 0 (the tap) is set. | |
| uint8_t | tone_page_pin (const tone_page_t *p) |
| The configured pin, from register LINK_TN_PIN. | |
| bool | tone_page_wanted (const tone_page_t *p) |
| Whether the capture is to run: enabled and not refused. | |
| uint64_t | tone_page_pins (const tone_page_t *p) |
| The pin as a reservation mask; 0 unless the capture is wanted. | |
| static bool | adc_pin (uint16_t pin) |
| The pins that are ADC inputs on either part the image may run on: GP26 to GP29 of the RP2350A, GP40 to GP47 of the RP2354B. | |
| static uint8_t | pin_refusal (const tone_page_t *p, const outputs_t *o, uint16_t pin, uint64_t taken) |
Why pin may not carry the tap, as the NACK says it, or 0 when it may. | |
| static bool | pin_free (const tone_page_t *p, const outputs_t *o, uint16_t pin, uint64_t taken) |
Whether pin passes pin_refusal() for the tap. | |
| bool | tone_page_pin_free (const tone_page_t *p, const outputs_t *o, uint64_t taken) |
| Whether the configured pin is free for the tap, as a write of ENABLE would judge it: the pull-down is put on it only if so. | |
| static bool | values_ok (tone_page_t *p, const uint16_t *c) |
| The values themselves, whatever is enabled: a set-up kept in flash is one a later enable can take without another write. | |
| static void | forget_status (tone_page_t *p) |
| A new set-up: what core 1 said under the old one is gone, so no read shows a tone or a flag before core 1 has run under the new one. | |
| uint8_t | tone_page_write (tone_page_t *p, uint8_t off, uint8_t n, const uint16_t *in, const outputs_t *o, uint64_t taken) |
| A write, validated whole before any of it is stored. | |
| void | tone_page_restore (tone_page_t *p, const uint16_t *cfg, const outputs_t *o, uint64_t taken) |
| The set-up kept in flash, loaded as a write would, at boot. | |
| void | tone_page_revert (tone_page_t *p, const uint16_t *cfg, bool refused) |
Put back the set-up cfg and refusal state a write replaced, after the wiring could not take it. | |
| void | tone_page_refuse (tone_page_t *p) |
| The wiring could not take the pin of an enabled set-up. | |
| void | tone_page_no_capture (tone_page_t *p) |
| No capture runs this boot (core 1 did not start): an enabled set-up is refused as tone_page_refuse() does, and every later write that enables the tap is refused with LINK_NACK_BAD_VALUE until the IOmcu restarts. A write with ENABLE clear is taken. | |
| void | tone_page_capture (tone_page_t *p) |
| The capture starts again (the tap enabled, or its pin moved): the ring empties and the order carries a new capture generation. | |
| void | tone_page_recapture (tone_page_t *p, uint32_t shift_ms) |
| The capture starts again with the ring kept: a refused write that put the old set-up back. | |
| uint8_t | tone_page_slots_check (const tone_page_t *p, const uint16_t *slots) |
| LINK_NACK_BAD_VALUE for an OUTPUTS page (slots, LINK_OS_COUNT registers) that binds a slot to the tap's pin; 0 otherwise. | |
| void | tone_page_cmd (const tone_page_t *p, bool run, tone_cmd_t *cmd) |
The order for core 1; run is whether the capture runs now. | |
| void | tone_page_publish (tone_page_t *p, const tone_status_t *st, const tone_rec_t *rec, size_t n) |
What core 1 handed back: its status, and the n beeps it finished. | |
| void | tone_page_beeps (tone_page_t *p, uint16_t gen, uint16_t cap_gen, const tone_rec_t *rec, size_t n) |
n beeps finished by core 1 under set-up gen and capture cap_gen, into the ring; dropped when the capture is not the one in force. | |
| void | tone_page_dropped (tone_page_t *p, uint32_t n) |
n beeps lost between the cores, added to LOST. | |
| static uint16_t | seq_of (uint64_t i) |
Beep index i (a count from 1) as the number the wire carries. | |
| static const tone_rec_t * | find (const tone_page_t *p, uint16_t sel) |
The ring's entry for beep number sel, or NULL if it is not there. | |
| void | tone_page_read (const tone_page_t *p, uint8_t off, uint8_t n, uint16_t *out) |
| A TONE page read. | |
|
static |
The pins that are ADC inputs on either part the image may run on: GP26 to GP29 of the RP2350A, GP40 to GP47 of the RP2354B.
Rated IOVDD + 0.5V, not fault tolerant.
| pin | GPIO number. |
|
static |
The ring's entry for beep number sel, or NULL if it is not there.
| p | The page state, read only. |
| sel | Wire beep number, as EVT_SEL carries it. |
sel of 0 or a beep not in the ring.
|
static |
A new set-up: what core 1 said under the old one is gone, so no read shows a tone or a flag before core 1 has run under the new one.
The ring and the counters are the capture's and stay.
| p | The page state. The status and window fields are cleared. |
|
static |
Whether pin passes pin_refusal() for the tap.
| p | The page state. |
| o | The outputs bank. |
| pin | GPIO number to judge. |
| taken | Mask of the pins other pages hold. |
|
static |
Why pin may not carry the tap, as the NACK says it, or 0 when it may.
BAD_VALUE for a pin no binding frees: past the bank, an ADC pin, or one the board reserves. BUSY for a pin something the panel sets up holds: another page's (taken), or an output's. The tap's own pin is not reserved against it.
| p | The page state, for the tap's own pin. |
| o | The outputs bank. |
| pin | GPIO number to judge. |
| taken | Mask of the pins other pages hold, bit n for GPn. |
|
static |
Beep index i (a count from 1) as the number the wire carries.
| i | Beep count, from 1 for the first beep. |
i of 0. | void tone_page_beeps | ( | tone_page_t * | p, |
| uint16_t | gen, | ||
| uint16_t | cap_gen, | ||
| const tone_rec_t * | rec, | ||
| size_t | n ) |
n beeps finished by core 1 under set-up gen and capture cap_gen, into the ring; dropped when the capture is not the one in force.
A beep finished under an earlier set-up of the same capture is taken: a change of the range keeps the ring and the numbering, and a beep the detector finished before it took the change is a beep that happened.
| p | The page state. |
| gen | The set-up generation the beeps finished under. Not checked. |
| cap_gen | The capture generation the beeps belong to. |
| rec | The beeps, n of them. |
| n | Number of beeps in rec. |
| void tone_page_capture | ( | tone_page_t * | p | ) |
The capture starts again (the tap enabled, or its pin moved): the ring empties and the order carries a new capture generation.
| p | The page state. |
| void tone_page_cmd | ( | const tone_page_t * | p, |
| bool | run, | ||
| tone_cmd_t * | cmd ) |
The order for core 1; run is whether the capture runs now.
Nothing is done when p or cmd is NULL.
| p | The page state. |
| run | Whether the capture is asked to run now. |
| cmd | Receives the order. Set to all zero, then filled in. |
| void tone_page_defaults | ( | uint16_t * | cfg | ) |
The set-up as a page starts, into cfg (LINK_TN_CONFIG_COUNT registers): the tap off, GP22, 400 to 6500Hz, 8%, 3ms, 3 periods.
| cfg | Receives LINK_TN_CONFIG_COUNT registers. Nothing is done when NULL. |
| void tone_page_dropped | ( | tone_page_t * | p, |
| uint32_t | n ) |
n beeps lost between the cores, added to LOST.
| p | The page state. Nothing is done when NULL. |
| n | Number of beeps lost. |
| bool tone_page_enabled | ( | const tone_page_t * | p | ) |
Whether ENABLE bit 0 (the tap) is set.
| p | The page state. |
p is NULL. | void tone_page_init | ( | tone_page_t * | p | ) |
Set the page to its start: the defaults, and the first beep number 1.
Nothing is done when p is NULL.
| p | The page state, overwritten. |
| void tone_page_no_capture | ( | tone_page_t * | p | ) |
No capture runs this boot (core 1 did not start): an enabled set-up is refused as tone_page_refuse() does, and every later write that enables the tap is refused with LINK_NACK_BAD_VALUE until the IOmcu restarts. A write with ENABLE clear is taken.
| p | The page state. |
| uint8_t tone_page_pin | ( | const tone_page_t * | p | ) |
The configured pin, from register LINK_TN_PIN.
| p | The page state. |
| bool tone_page_pin_free | ( | const tone_page_t * | p, |
| const outputs_t * | o, | ||
| uint64_t | taken ) |
Whether the configured pin is free for the tap, as a write of ENABLE would judge it: the pull-down is put on it only if so.
| p | The page state. |
| o | The outputs bank. |
| taken | Mask of the pins other pages hold. |
p or o is NULL. | uint64_t tone_page_pins | ( | const tone_page_t * | p | ) |
The pin as a reservation mask; 0 unless the capture is wanted.
| p | The page state. |
| void tone_page_publish | ( | tone_page_t * | p, |
| const tone_status_t * | st, | ||
| const tone_rec_t * | rec, | ||
| size_t | n ) |
What core 1 handed back: its status, and the n beeps it finished.
Taken when st was made under the set-up in force; ignored otherwise.
| p | The page state. |
| st | The status core 1 returned. |
| rec | The beeps core 1 finished, n of them. |
| n | Number of beeps in rec. |
| void tone_page_read | ( | const tone_page_t * | p, |
| uint8_t | off, | ||
| uint8_t | n, | ||
| uint16_t * | out ) |
A TONE page read.
Nothing is done when p or out is NULL, or when off and n reach past LINK_TN_COUNT.
| p | The page state, not changed. |
| off | First register, 0 to LINK_TN_COUNT - 1. |
| n | Number of registers to read. |
| out | Receives the n register values. |
| void tone_page_recapture | ( | tone_page_t * | p, |
| uint32_t | shift_ms ) |
The capture starts again with the ring kept: a refused write that put the old set-up back.
The order carries a new capture generation; the beeps already in the ring stay readable, because the panel was told nothing restarted. shift_ms, the time from the old capture's start to the new one's, is added to every later beep's start, so EVT_START_MS keeps its origin. A beep under way was cut: FLAGS shows OVERRUN until the next capture.
| p | The page state. |
| shift_ms | Milliseconds from the old capture's start to the new one's. |
| void tone_page_refuse | ( | tone_page_t * | p | ) |
The wiring could not take the pin of an enabled set-up.
Nothing changes unless the set-up is enabled.
| p | The page state. |
| void tone_page_restore | ( | tone_page_t * | p, |
| const uint16_t * | cfg, | ||
| const outputs_t * | o, | ||
| uint64_t | taken ) |
The set-up kept in flash, loaded as a write would, at boot.
A set-up that is not valid starts as the defaults. A valid one that enables the tap on a pin that is no longer free is kept, and the tap does not run: FLAGS says PIN_REFUSED and the pin is not reserved.
Nothing is done when p, cfg or o is NULL.
| p | The page state, overwritten. |
| cfg | The kept set-up, LINK_TN_CONFIG_COUNT registers. |
| o | The outputs bank, for the pin's reservation. |
| taken | Mask of the pins other pages hold, as tone_page_write() takes it. |
| void tone_page_revert | ( | tone_page_t * | p, |
| const uint16_t * | cfg, | ||
| bool | refused ) |
Put back the set-up cfg and refusal state a write replaced, after the wiring could not take it.
Nothing is done when p or cfg is NULL.
| p | The page state, overwritten. |
| cfg | The set-up to put back, LINK_TN_CONFIG_COUNT registers. |
| refused | The refusal state to put back. |
| uint8_t tone_page_slots_check | ( | const tone_page_t * | p, |
| const uint16_t * | slots ) |
LINK_NACK_BAD_VALUE for an OUTPUTS page (slots, LINK_OS_COUNT registers) that binds a slot to the tap's pin; 0 otherwise.
| p | The page state. |
| slots | The OUTPUTS page, LINK_OS_COUNT registers. |
slots. | bool tone_page_wanted | ( | const tone_page_t * | p | ) |
Whether the capture is to run: enabled and not refused.
| p | The page state. |
| uint8_t tone_page_write | ( | tone_page_t * | p, |
| uint8_t | off, | ||
| uint8_t | n, | ||
| const uint16_t * | in, | ||
| const outputs_t * | o, | ||
| uint64_t | taken ) |
A write, validated whole before any of it is stored.
Registers 0 to 7 are the set-up and EVT_SEL alone is the beep shown; anything else is read only. Refused: off the page (BAD_RANGE); a read-only register (READ_ONLY); a value out of its range, register 7 other than 0, a set-up tone_init() refuses, and with the tap enabled a pin past the bank, an ADC pin or one the board reserves (BAD_VALUE); with the tap enabled on a page that runs no capture this boot (tone_page_no_capture(), BAD_VALUE: no freed pin makes it good before a restart); with the tap enabled a pin in taken or bound to an output (BUSY, since 4.17: freed, the same write is taken). A write of the set-up in force is taken, unless the tap is refused: then it is tried again.
taken is the pins another page holds: SUPPLY's, PROG's, and SENSE's including the ones core 1 has not let go of yet. Every reserved pin outside it is judged a board pin.
| p | The page state, changed only when the write is taken. |
| off | First register, 0 to LINK_TN_COUNT - 1. |
| n | Number of registers to write. 0 is taken with no change. |
| in | The n new register values. |
| o | The outputs bank, for the pin's reservation. |
| taken | Mask of the pins other pages hold, bit n for GPn. |
taken or bound to an output.
|
static |
The values themselves, whatever is enabled: a set-up kept in flash is one a later enable can take without another write.
The detector's own verdict is the last word: tone_init() refuses a gap shorter than the lowest tone's period and any range the tick clock cannot resolve.
| p | The page state; its scratch detector is set by tone_init(). |
| c | The set-up to judge, LINK_TN_CONFIG_COUNT registers. |