Sense.ADC.6
Six-channel ADC input driver for the Sense.ADC.6 tile.
Examples
Typical use (Cores SDK)
tile_t adc;
tile_sense_adc_6_init(core_tiles_pal(&core_i2c1), 0, &adc, NULL);
while (1) {
if (tile_sense_adc_6_update(&adc)) {
int mv = tile_sense_adc_6_read_mv(&adc, 0);
...
}
core_delay_ms(10);
}API reference
Initialization
tile_sense_adc_6_find
uint8_t tile_sense_adc_6_find(tiles_pal_t *hal, uint8_t instance)Check whether a tile is present.
- hal
- Tiles HAL handle (I2C bus)
- instance
- Device instance (0-3, selects the default addresses)
Returns 1 if a Sense.ADC.6 answered, 0 otherwise
tile_sense_adc_6_init
void tile_sense_adc_6_init(tiles_pal_t *hal, uint8_t instance, tile_t *tile, const sense_adc_6_cfg_t *cfg)Verifies the tile's identity and reads its current settings. Applies any rate/oversamp/window given in cfg; otherwise leaves the tile's stored settings alone.
- hal
- Tiles HAL handle (I2C bus)
- instance
- Device instance (0-3)
- tile
- Tile handle to initialize
- cfg
- Optional config, NULL for defaults
Runtime
tile_sense_adc_6_update
Studiouint8_t tile_sense_adc_6_update(tile_t *tile)One bus transaction collects all six channels, the status and the sequence number from the same instant. Call this, then read the channels with read_mv(), which costs no bus traffic.
Returns 1 on success, 0 if the read failed
tile_sense_adc_6_read_mv
Studiouint16_t tile_sense_adc_6_read_mv(tile_t *tile, uint8_t ch)Millivolts on one channel, from the last update().
- ch
- [0..5] Channel. CH0 is pad 2, CH1 pad 3, CH2 pad 6, CH3 pad 7, CH4 pad 8, CH5 pad 9.
Returns Millivolts, or 0 if the channel is out of range
tile_sense_adc_6_sequence
Studiouint8_t tile_sense_adc_6_sequence(tile_t *tile)Unchanged between two updates means you polled faster than the tile publishes, not that it stopped.
tile_sense_adc_6_is_valid
Studiouint8_t tile_sense_adc_6_is_valid(tile_t *tile)True when the last set is current: sampling is running and settled after any settings change.
tile_sense_adc_6_status
Studiouint8_t tile_sense_adc_6_status(tile_t *tile)Status bits (SENSE_ADC_6_ST_*) from the last update().
tile_sense_adc_6_supply_mv
Studiouint16_t tile_sense_adc_6_supply_mv(tile_t *tile)The tile's measured supply in millivolts, which is also the full-scale input voltage.
Events
Config
tile_sense_adc_6_set_rate
Studiouint8_t tile_sense_adc_6_set_rate(tile_t *tile, uint8_t rate_hz, uint8_t oversamp, uint8_t window)Applied as a set, because the three only make sense together. Takes effect within one output period; readings are marked invalid until the filter has refilled, so you never average across the change. Limits: oversamp x window at most 32 sweeps, and rate x oversamp at most 8000 sweeps per second. Out-of-range combinations are rejected and the tile keeps running as it was.
- rate_hz
- [1..250] Output rate in Hz.
- oversamp
- [1..32] Sweeps averaged per output period.
- window
- [1..2] Output periods averaged. 2 halves the null frequency.
Returns 1 if applied, 0 if rejected
tile_sense_adc_6_get_rate
Studiouint8_t tile_sense_adc_6_get_rate(tile_t *tile)The tile's current output rate in Hz.
tile_sense_adc_6_get_oversamp
Studiouint8_t tile_sense_adc_6_get_oversamp(tile_t *tile)Sweeps averaged per output period.
tile_sense_adc_6_get_window
Studiouint8_t tile_sense_adc_6_get_window(tile_t *tile)Output periods averaged (1 or 2).
tile_sense_adc_6_save
Studiouint8_t tile_sense_adc_6_save(tile_t *tile)Writes the tile's non-volatile memory, which holds the bus for up to about 30 ms and only writes what actually changed. Do it on a bench, not while other tiles are being polled on the same bus.
Returns 1 on success, 0 on failure
Advanced
tile_sense_adc_6_set_address
Studiouint8_t tile_sense_adc_6_set_address(tile_t *tile, uint8_t addr)For several tiles on one bus. The new address takes effect at the tile's NEXT POWER-UP, not immediately, so this handle keeps working until then. Address one tile at a time: they all ship on the same default address, so give each its own before putting them on a shared bus.
- addr
- [8..119] New 7-bit address. 0x08 to 0x77.
Returns 1 if stored, 0 if rejected or the write failed
Other
tile_sense_adc_6_read_all
void tile_sense_adc_6_read_all(tile_t *tile, uint16_t *out)Copy all six channels from the last update() into an array.
- out
- Destination, at least SENSE_ADC_6_CHANNELS entries
tile_sense_adc_6_channel_pad
uint8_t tile_sense_adc_6_channel_pad(uint8_t ch)The pad number a channel is wired to (CH0 is pad 2, and so on).
- ch
- [0..5] Channel.
Returns Pad number, or 0 if the channel is out of range
Constants
| TILE_SENSE_ADC_6_VERSION_MAJOR | 1 | |
| TILE_SENSE_ADC_6_VERSION_MINOR | 0 | |
| TILE_SENSE_ADC_6_VERSION_PATCH | 0 | |
| SENSE_ADC_6_CHANNELS | 6 | |
| SENSE_ADC_6_I2C_ADDR | 0x28 | |
| SENSE_ADC_6_ADDR_MIN | 0x08 | |
| SENSE_ADC_6_ADDR_MAX | 0x77 | |
| SENSE_ADC_6_RATE_MAX | 250 | output rate, Hz |
| SENSE_ADC_6_OVERSAMP_MAX | 32 | sweeps averaged per period |
| SENSE_ADC_6_WINDOW_MAX | 2 | periods averaged |

