|
| 1 | +/**************************************************************************** |
| 2 | + * arch/arm/src/rtl8721f/ameba_adc_chip.h |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + * |
| 6 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 7 | + * contributor license agreements. See the NOTICE file distributed with |
| 8 | + * this work for additional information regarding copyright ownership. The |
| 9 | + * ASF licenses this file to you under the Apache License, Version 2.0 (the |
| 10 | + * "License"); you may not use this file except in compliance with the |
| 11 | + * License. You may obtain a copy of the License at |
| 12 | + * |
| 13 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | + * |
| 15 | + * Unless required by applicable law or agreed to in writing, software |
| 16 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 17 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 18 | + * License for the specific language governing permissions and limitations |
| 19 | + * under the License. |
| 20 | + * |
| 21 | + ****************************************************************************/ |
| 22 | + |
| 23 | +#ifndef __ARCH_ARM_SRC_RTL8721F_AMEBA_ADC_CHIP_H |
| 24 | +#define __ARCH_ARM_SRC_RTL8721F_AMEBA_ADC_CHIP_H |
| 25 | + |
| 26 | +/**************************************************************************** |
| 27 | + * Included Files |
| 28 | + ****************************************************************************/ |
| 29 | + |
| 30 | +#include <nuttx/config.h> |
| 31 | + |
| 32 | +#include <stdint.h> |
| 33 | + |
| 34 | +/**************************************************************************** |
| 35 | + * Pre-processor Definitions |
| 36 | + ****************************************************************************/ |
| 37 | + |
| 38 | +/* Per-chip ADC wiring for RTL8721F (amebagreen2). The shared driver |
| 39 | + * (arch/arm/src/common/ameba/ameba_adc.c) includes this header to learn how |
| 40 | + * many channels the converter can list, the crossbar pad-mux code that turns |
| 41 | + * a pad into an analog input, and the peripheral-clock masks. A port to |
| 42 | + * another Ameba chip supplies a same-named header on the chip include path; |
| 43 | + * the shared driver is never edited -- it reads only the macros below, and |
| 44 | + * it drives the ADC through the SDK fwlib API, which internally selects the |
| 45 | + * secure/non-secure register alias (via TrustZone_IsSecure()), so no |
| 46 | + * register base appears here at all. |
| 47 | + * |
| 48 | + * Values below are taken from the amebagreen2 fwlib headers (verified, not |
| 49 | + * guessed): PINMUX_FUNCTION_ADC=5 (ameba_pinmux.h), ADC_IRQ=42 |
| 50 | + * (ameba_vector_table.h), APBPeriph_ADC and APBPeriph_ADC_CLOCK both |
| 51 | + * bit30|bit23 (sysreg_lsys.h). RTL8721F does not route the ADC through the |
| 52 | + * cap-touch/CTC block, so no second clock domain is needed and |
| 53 | + * AMEBA_ADC_AUXCLK_* stay undefined. |
| 54 | + * |
| 55 | + * External channels CH0..CH7 map to pads PA20,PA19,PA18,PA17,PA15,PA14, |
| 56 | + * PA13,PA12 (from ameba_adc.h ADC_CHx_PIN); CH8..CH10 and CH14 are fixed |
| 57 | + * internal channels with no pad. The 16-bit conversion word (channel id in |
| 58 | + * [19:16], data in [15:0]) is identical on every current Ameba chip, so the |
| 59 | + * driver extracts it directly and no macro is needed here. |
| 60 | + */ |
| 61 | + |
| 62 | +#define AMEBA_ADC_NCHAN 12 /* ADC_CH_NUM: CH0..CH7 ext, rest int */ |
| 63 | +#define AMEBA_ADC_MAXLIST 16 /* Channel-switch list depth (Cvlist) */ |
| 64 | +#define AMEBA_ADC_PINMUX_FID 5 /* PINMUX_FUNCTION_ADC */ |
| 65 | +#define AMEBA_ADC_IRQ 42 /* ADC_IRQ (unused by this polling drv) */ |
| 66 | + |
| 67 | +/* sizeof(fwlib ADC_InitTypeDef): OpMode/CvlistLen/Cvlist[16] then |
| 68 | + * RxThresholdLevel/SpecialCh/SamplePeriodUs(u16) -> 22 bytes. The shared |
| 69 | + * driver sizes its stack mirror from this so ADC_StructInit() cannot |
| 70 | + * overflow it. |
| 71 | + */ |
| 72 | + |
| 73 | +#define AMEBA_ADC_INIT_SIZE 22 |
| 74 | + |
| 75 | +/* APBPeriph_ADC (function) and APBPeriph_ADC_CLOCK masks. Equal on this |
| 76 | + * chip; both set the bit30 group selector and bit23 for the LP ADC block. |
| 77 | + * RTL8721F needs no second clock domain, so AMEBA_ADC_AUXCLK_* are left |
| 78 | + * undefined (amebalite/amebasmart define them to gate APBPeriph_CTC too). |
| 79 | + */ |
| 80 | + |
| 81 | +#define AMEBA_ADC_APBPERIPH (((uint32_t)1 << 30) | ((uint32_t)1 << 23)) |
| 82 | +#define AMEBA_ADC_APBPERIPH_CLK (((uint32_t)1 << 30) | ((uint32_t)1 << 23)) |
| 83 | + |
| 84 | +#endif /* __ARCH_ARM_SRC_RTL8721F_AMEBA_ADC_CHIP_H */ |
0 commit comments