commit c15958b6478dd790561a1b8c46eb2ae0253254a8 Author: cfif Date: Wed Dec 4 13:10:48 2024 +0300 Init diff --git a/Adcs.c b/Adcs.c new file mode 100644 index 0000000..7d85a7a --- /dev/null +++ b/Adcs.c @@ -0,0 +1,36 @@ +// +// Created by xemon on 29.08.22. +// +#include "Adcs.h" +#include "n32g45x.h" +#include "GpioPin.h" + +tAdcs ADCS; + +void ADC_RCC_Configuration() { + // Enable ADC1 + RCC_EnableAHBPeriphClk(RCC_AHB_PERIPH_ADC1, ENABLE); + RCC_EnableAHBPeriphClk(RCC_AHB_PERIPH_ADC2, ENABLE); + // RCC_ADCHCLK_DIV16 + ADC_ConfigClk(ADC_CTRL3_CKMOD_AHB, RCC_ADCHCLK_DIV16); + RCC_ConfigAdc1mClk(RCC_ADC1MCLK_SRC_HSE, RCC_ADC1MCLK_DIV8); //selsect HSE as RCC ADC1M CLK Source +} + +void Adcs_Init() { + tAdcs *env = &ADCS; + + ADC_RCC_Configuration(); + + GpioPin_Init(GPIOA, GPIO_PIN_1, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_PIN_NOREVERSE); + env->gnssAntenna = ADC_Initial(ADC1, ADC1_Channel_02_PA1, 1, 1, 0, 1000); + env->gnssAntennaIo = vAdcGetIo(&env->gnssAntenna); + + GpioPin_Init(GPIOA, GPIO_PIN_2, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_PIN_NOREVERSE); + env->speaker = ADC_Initial(ADC1, ADC1_Channel_11_PA2, 1, 1, 0, 1000); + env->speakerIo = vAdcGetIo(&env->speaker); + + GpioPin_Init(GPIOC, GPIO_PIN_4, GPIO_Mode_IN_FLOATING, GPIO_Speed_50MHz, GPIO_PIN_NOREVERSE); + env->battery = ADC_Initial(ADC2, ADC2_Channel_05_PC4, 2900, 1800, 0, 1000); + env->batteryIo = vAdcGetIo(&env->battery); + +} \ No newline at end of file diff --git a/Adcs.h b/Adcs.h new file mode 100644 index 0000000..5a812c6 --- /dev/null +++ b/Adcs.h @@ -0,0 +1,26 @@ +// +// Created by xemon on 29.08.22. +// + +#ifndef UVEOS_DEMO_ON_NIIET_MCU_ADCS_H +#define UVEOS_DEMO_ON_NIIET_MCU_ADCS_H + +#include "AdcNation.h" + + +typedef struct { + tAdcNation gnssAntenna; + tAdcIO gnssAntennaIo; + + tAdcNation speaker; + tAdcIO speakerIo; + + tAdcNation battery; + tAdcIO batteryIo; +} tAdcs; + +extern tAdcs ADCS; + +void Adcs_Init(); + +#endif //UVEOS_DEMO_ON_NIIET_MCU_ADCS_H diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..8802594 --- /dev/null +++ b/modular.json @@ -0,0 +1,22 @@ +{ + "dep": [ + { + "type": "git", + "provider": "NAVIGATOR_UVEOS_NATION_TELIT", + "repo": "Adc_NATION_N32G45X" + }, + { + "type": "git", + "provider": "NAVIGATOR_UVEOS_NATION_TELIT", + "repo": "AdcInterface" + } + ], + "cmake": { + "inc_dirs": [ + "./" + ], + "srcs": [ + "*.c" + ] + } +} \ No newline at end of file