|
STC15W408AS library 0.15.0
|
Enumerations | |
| enum | adc_speed_t { ADC_SPEED_540 = 0b00000000 , ADC_SPEED_360 = 0b00100000 , ADC_SPEED_180 = 0b01000000 , ADC_SPEED_90 = 0b01100000 } |
| ADC speed enum. More... | |
init | |
ADC initializaion and destroy routines | |
| #define | adc_init_input_only(p1_pin, adrj_flag, speed) |
| ADC initialization in pin input only mode. | |
| #define | adc_init_open_drain(p1_pin, adrj_flag, speed) |
| ADC initialization in pin open drain mode. | |
| #define | adc_destroy(void) |
| Deinitialize ADC module. | |
sync | |
ADC sync routines | |
| #define | adc_read_sync(value) |
| ADC read routine. | |
async | |
ADC async routines | |
| #define | adc_async_read_start() |
| Start async ADC read operation if not started. | |
| #define | is_adc_async_read_started() (test_if_bit_set(ADC_CONTR, 1 << ADC_START_BIT) && (ADC_CONTR & ADC_POWER_ON_MSK)) |
| get ADC start and power flags | |
| #define | adc_async_read_finish() (bit_clr(ADC_CONTR, ~(1 << ADC_FLAG_BIT))) |
| Clear ADC result ready flag. | |
| #define | adc_async_get_result() (test_if_bit_set(CLK_DIV, 1 << ADRJ_BIT) ? (ADC_RESL << ADC_LOW_BITS_COUNT) | (ADC_RES & ADC_LOW_BITS_MSK) : (ADC_RES << ADC_LOW_BITS_COUNT) | (ADC_RESL & ADC_LOW_BITS_MSK)) |
| Async get ADC result. | |
Functions and data structures related to ADC module
ADC could be used in sync or async modes.
In sync mode read ADC result blocks until result is not ready.
In async mode read is started in non blocking mode. ADC ready raise an interrupt. In async mode mcu interrupts and ADC interrupt should be enabled before start reading.
| #define adc_async_get_result | ( | ) | (test_if_bit_set(CLK_DIV, 1 << ADRJ_BIT) ? (ADC_RESL << ADC_LOW_BITS_COUNT) | (ADC_RES & ADC_LOW_BITS_MSK) : (ADC_RES << ADC_LOW_BITS_COUNT) | (ADC_RESL & ADC_LOW_BITS_MSK)) |
Async get ADC result.
Retrieves the result of a completed asynchronous ADC conversion
This routine should be used inside ADC interrupt handler. Typically after call this routine adc_async_read_finish() should be called to clear ADC result ready flag.
| #define adc_async_read_finish | ( | ) | (bit_clr(ADC_CONTR, ~(1 << ADC_FLAG_BIT))) |
Clear ADC result ready flag.
| #define adc_async_read_start | ( | ) |
Start async ADC read operation if not started.
Set ADC start flag if it does not set After that program is not bloked. When result is ready MCU generate ADC interrupt.
| #define adc_destroy | ( | void | ) |
Deinitialize ADC module.
Stops ongoing conversion, clears status flag, and disables analog function on all P1 pins.
| #define adc_init_input_only | ( | p1_pin, | |
| adrj_flag, | |||
| speed | |||
| ) |
ADC initialization in pin input only mode.
Configures the ADC for 10-bit resolution, uses the internal voltage reference.
| p1_pin | uint8_t P1 pin number. Values from 0 to 7. |
| adrj_flag | bool ADC_RES-ADC_RESL or ADC_RESL-ADC_RES result bits order |
| speed | adc_speed_t ADC convertion speed |
| #define adc_init_open_drain | ( | p1_pin, | |
| adrj_flag, | |||
| speed | |||
| ) |
ADC initialization in pin open drain mode.
Configures the ADC for 10-bit resolution, uses the internal voltage reference.
| p1_pin | uint8_t P1 pin number. Values from 0 to 7. |
| adrj_flag | bool ADC_RES-ADC_RESL or ADC_RESL-ADC_RES result bits order |
| speed | adc_speed_t ADC convertion speed |
| #define adc_read_sync | ( | value | ) |
ADC read routine.
Clear result ready ADC flag and start ADC. Waiting for result is ready (flag up). After ADC flag is up by hardware store result to value reference
| value | uint16_t 10-bit ADC result |
| #define is_adc_async_read_started | ( | ) | (test_if_bit_set(ADC_CONTR, 1 << ADC_START_BIT) && (ADC_CONTR & ADC_POWER_ON_MSK)) |
get ADC start and power flags
| enum adc_speed_t |