|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Temperature Sensor (TSN) register layout for the Renesas RA8D2. More...
Go to the source code of this file.
Data Structures | |
| struct | r_tsn_ctrl_regs_t |
| TSN control block register window. More... | |
| struct | r_tsn_cal_regs_t |
| TSN factory-calibration block (read-only on hardware). More... | |
Enumerations | |
| enum | ra8_tsn_addr_t : uintptr_t { k_ra8_tsn_ctrl_base_addr = 0x40235000UL , k_ra8_tsn_cal_base_addr = 0x02C1EDA0UL } |
| enum | ra8_tscr_bit_t : uint8_t { k_ra8_tscr_bit_tsen = 4U , k_ra8_tscr_bit_tsoe = 7U } |
| Bit positions in TSCR (Temperature Sensor Control Register). More... | |
| enum | ra8_tscr_mask_t : uint8_t { k_ra8_tscr_mask_tsen = (uint8_t)(1U << 4U) , k_ra8_tscr_mask_tsoe = (uint8_t)(1U << 7U) , k_ra8_tscr_mask_all = (uint8_t)((1U << 4U) | (1U << 7U)) } |
| Bit masks for TSCR (Temperature Sensor Control Register). More... | |
| enum | ra8_tscdr_field_t : uint16_t { k_ra8_tscdr_data_mask = 0x0FFFU } |
| Field widths for TSCDR / TSCDR2 calibration words. More... | |
| enum | ra8_tsn_cal_t : int32_t { k_ra8_tsn_slope_uv_per_c = 4000 , k_ra8_tsn_ref_temp_degc = 25 } |
| Calibration constants for the degC conversion. More... | |
| enum | ra8_tsn_adc_const_t : int32_t { k_ra8_tsn_adc_avcc_uv = 3300000 , k_ra8_tsn_adc_full_scale = 4096 , k_ra8_tsn_uv_per_mv = 1000 } |
| ADC-side scaling constants used by the two-point conversion. More... | |
Functions | |
| static volatile r_tsn_ctrl_regs_t * | ra8_tsn (void) |
| Get pointer to the TSN control block (HUM Ch 55.2.1 p 3498). | |
| static volatile const r_tsn_cal_regs_t * | ra8_tsn_cal (void) |
| Get pointer to the factory-calibration block (TSCDR + TSCDR2). | |
| static volatile const uint32_t * | ra8_tsn_tscdr (void) |
| Get pointer to the factory-programmed calibration word (TSCDR). | |
Temperature Sensor (TSN) register layout for the Renesas RA8D2.
The RA8D2 temperature sensor has two halves:
\[ T(degC) = \frac{(V_{raw} - V_{ref}) \times slope}{1000} + T_{ref} \]
where V_raw is the raw ADC sample (14-bit right-aligned), V_ref is TSCDR (reference code at T_ref degC), and slope is BSP_FEATURE_TSN_SLOPE = 4000 uV/degC for the RA8D2.
| Block | Offset | Reg | Width | Purpose |
|---|---|---|---|---|
| TSN_CTRL | 0x00 | TSCR | 8 | Sensor control (TSEN) |
| TSN_CAL | 0x00 | TSCDR | 32 | Reference code @ T_ref |
Definition in file ra8_tsn_regs.h.
| enum ra8_tscdr_field_t : uint16_t |
Field widths for TSCDR / TSCDR2 calibration words.
HUM Ch 55.2.2 "TSCDR : Temperature Sensor Calibration Data Register", p 3498-3499. Only the lower 12 bits are meaningful; reserved bits read 0. The same width applies to live conversion samples that the ADC produces for the temperature-sensor channel.
| Enumerator | |
|---|---|
| k_ra8_tscdr_data_mask | 12-bit data mask (HUM Ch 55.2.2 p 3498). |
Definition at line 94 of file ra8_tsn_regs.h.
| enum ra8_tscr_bit_t : uint8_t |
Bit positions in TSCR (Temperature Sensor Control Register).
HUM Ch 55.2.1 "TSCR : Temperature Sensor Control Register", p 3498.
| Enumerator | |
|---|---|
| k_ra8_tscr_bit_tsen | 1 = sensor enabled, 0 = off. |
| k_ra8_tscr_bit_tsoe | 1 = output enabled to ADC_B. |
Definition at line 63 of file ra8_tsn_regs.h.
| enum ra8_tscr_mask_t : uint8_t |
Bit masks for TSCR (Temperature Sensor Control Register).
Pre-shifted masks corresponding to the bit positions in ra8_tscr_bit_t. k_ra8_tscr_mask_all covers every documented bit so callers (and unit tests) can ignore any reserved bits the silicon happens to surface (HUM Ch 55.2.1 "TSCR" p 3498).
| Enumerator | |
|---|---|
| k_ra8_tscr_mask_tsen | TSEN bit (sensor enable). |
| k_ra8_tscr_mask_tsoe | TSOE bit (ADC output enable). |
| k_ra8_tscr_mask_all | TSEN | TSOE. |
Definition at line 78 of file ra8_tsn_regs.h.
| enum ra8_tsn_adc_const_t : int32_t |
ADC-side scaling constants used by the two-point conversion.
The two-point trim formula from HUM Ch 55.3.1 (p 3499-3500) needs three magic-free numbers:
| Enumerator | |
|---|---|
| k_ra8_tsn_adc_avcc_uv | AVCC = 3.3 V expressed in uV. |
| k_ra8_tsn_adc_full_scale | 12-bit ADC full-scale. |
| k_ra8_tsn_uv_per_mv | 1000-x scale (degC -> mC). |
Definition at line 200 of file ra8_tsn_regs.h.
| enum ra8_tsn_addr_t : uintptr_t |
| Enumerator | |
|---|---|
| k_ra8_tsn_ctrl_base_addr | TSN control block. |
| k_ra8_tsn_cal_base_addr | Factory calibration. |
Definition at line 51 of file ra8_tsn_regs.h.
| enum ra8_tsn_cal_t : int32_t |
Calibration constants for the degC conversion.
From BSP_FEATURE_TSN_SLOPE (4000 uV/degC) and the reference temperature embedded in the RA8D2 HUM section "Temperature Sensor".
| Enumerator | |
|---|---|
| k_ra8_tsn_slope_uv_per_c | Slope in microvolts per degC. |
| k_ra8_tsn_ref_temp_degc | Reference temperature (degC). |
Definition at line 173 of file ra8_tsn_regs.h.
|
inlinestatic |
Get pointer to the TSN control block (HUM Ch 55.2.1 p 3498).
Definition at line 139 of file ra8_tsn_regs.h.
References k_ra8_tsn_ctrl_base_addr.
Referenced by ra8_tsn_clear_status(), ra8_tsn_deinit(), ra8_tsn_get_status(), and ra8_tsn_init().
|
inlinestatic |
Get pointer to the factory-calibration block (TSCDR + TSCDR2).
HUM Ch 55.2.2 "TSCDR / TSCDR2", p 3498-3499. The block is read-only on hardware – callers must treat the pointer's targets as const even though the struct fields are plain volatile uint32_t so unit tests can poke them.
Definition at line 153 of file ra8_tsn_regs.h.
References k_ra8_tsn_cal_base_addr.
Referenced by ra8_tsn_convert_to_milli_c().
|
inlinestatic |
Get pointer to the factory-programmed calibration word (TSCDR).
Definition at line 160 of file ra8_tsn_regs.h.
References k_ra8_tsn_cal_base_addr.