STC15W408AS library 0.15.0
Loading...
Searching...
No Matches
Macros | Enumerations
adc.h File Reference
#include <sys.h>
#include <bits.h>
#include <stdint.h>
#include <stdbool.h>
#include <gpio.h>
Include dependency graph for adc.h:

Go to the source code of this file.

Macros

#define ADC_START_BIT   3
 ADC CONTR register ADC_START bit position.
 
#define ADC_FLAG_BIT   4
 ADC CONTR register ADC_FLAG bit position.
 
#define ADRJ_BIT   5
 CLKDIV register ADRJ bit position.
 
#define ADC_POWER_ON_MSK   0x80
 
#define ADC_LOW_BITS_COUNT   2
 ADC result shift offset.
 
#define ADC_LOW_BITS_MSK   0x03
 ADC result low bits mask.
 
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.
 

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...
 

Macro Definition Documentation

◆ ADC_POWER_ON_MSK

#define ADC_POWER_ON_MSK   0x80

ADC CONTR register ADC_POWER_ON bit mask