|
| 1 | +/* |
| 2 | + * Copyright 2024 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | + |
| 18 | +#pragma once |
| 19 | + |
| 20 | +#include "board/board.h" |
| 21 | + |
| 22 | +#include <stdbool.h> |
| 23 | +#include <stdint.h> |
| 24 | + |
| 25 | +//! Start using the I2C bus to which \a slave is connected |
| 26 | +//! Must be called before any other reads or writes to the slave are performed |
| 27 | +//! @param slave I2C slave reference, which will identify the bus to use |
| 28 | + |
| 29 | + |
| 30 | +//! Init all adc supported |
| 31 | +//! Must be called before any other deviec use adc |
| 32 | +//! @param null |
| 33 | +extern int adc_init(void); |
| 34 | + |
| 35 | +//! Enable or disable adc and channel, eanble adc will config pinmux |
| 36 | +//! Must enable adc before get adc value |
| 37 | +//! @param adc_config must init member: adc, adc_channel, gpio_pin;adc_channel:0~7; if don't need gpio_pin , gpio_pin should config as 0xFF; |
| 38 | +extern int adc_enabled(ADCInputConfig* adc_config, bool enabled); |
| 39 | + |
| 40 | +//! Get special adc channel value |
| 41 | +//! Must enable adc before get adc value |
| 42 | +//! @param adc_config must init member: adc, adc_channel;adc_channel:0~7; |
| 43 | +extern int get_adc_value(ADCInputConfig* adc_config, uint32_t *value); |
| 44 | +extern void example_adc(ADCInputConfig* adc_config); |
|
0 commit comments