parent
b2244f9083
commit
b837c2aef0
Binary file not shown.
|
|
@ -1678,7 +1678,7 @@
|
||||||
<Compile Include="src\ASF\sam0\utils\syscalls\gcc\syscalls.c">
|
<Compile Include="src\ASF\sam0\utils\syscalls\gcc\syscalls.c">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="src\include\adc_user.c">
|
<Compile Include="src\include\adc_user.h">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="src\include\dac_user.h">
|
<Compile Include="src\include\dac_user.h">
|
||||||
|
|
@ -1696,7 +1696,7 @@
|
||||||
<Compile Include="src\main.c">
|
<Compile Include="src\main.c">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="src\source\adc_user.h">
|
<Compile Include="src\source\adc_user.c">
|
||||||
<SubType>compile</SubType>
|
<SubType>compile</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="src\source\dac_user.c">
|
<Compile Include="src\source\dac_user.c">
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* adc.h
|
||||||
|
*
|
||||||
|
* Created: 03.01.2021 23:34:13
|
||||||
|
* Author: Lexus
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ADC_H_
|
||||||
|
#define ADC_H_
|
||||||
|
|
||||||
|
#define chan_NTC_MCU ADC_POSITIVE_INPUT_PIN1
|
||||||
|
#define chan_NTC_TEC ADC_POSITIVE_INPUT_PIN5
|
||||||
|
#define chan_LFB ADC_POSITIVE_INPUT_PIN19
|
||||||
|
#define chan_CS ADC_POSITIVE_INPUT_PIN4
|
||||||
|
#define chan_SFB ADC_POSITIVE_INPUT_PIN18
|
||||||
|
#define chan_VTEC ADC_POSITIVE_INPUT_PIN6
|
||||||
|
#define chan_ITEC ADC_POSITIVE_INPUT_PIN7
|
||||||
|
|
||||||
|
typedef enum adc_positive_input ADC_chan_t;
|
||||||
|
|
||||||
|
void configure_adc(void);
|
||||||
|
uint16_t adc_read_value(void);
|
||||||
|
float adc_get_V(uint16_t value);
|
||||||
|
float adc_get_Q(uint16_t value);
|
||||||
|
uint16_t adc_read_value_spec(ADC_chan_t);
|
||||||
|
float adc_get_V_spec(ADC_chan_t chan);
|
||||||
|
#endif /* ADC_H_ */
|
||||||
|
|
@ -9,6 +9,6 @@
|
||||||
#ifndef DAC_USER_H_
|
#ifndef DAC_USER_H_
|
||||||
#define DAC_USER_H_
|
#define DAC_USER_H_
|
||||||
|
|
||||||
void configure_dac_channel(void)
|
void configure_dac_channel(void);
|
||||||
|
|
||||||
#endif /* DAC_USER_H_ */
|
#endif /* DAC_USER_H_ */
|
||||||
|
|
@ -10,6 +10,6 @@
|
||||||
#define REALSENCE_H_
|
#define REALSENCE_H_
|
||||||
|
|
||||||
void rs_configure_port_pins(void);
|
void rs_configure_port_pins(void);
|
||||||
void rs_set(bool value);
|
void rs_set(_Bool value);
|
||||||
|
|
||||||
#endif /* REALSENCE_H_ */
|
#endif /* REALSENCE_H_ */
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#ifndef TMPGOOD_H_
|
#ifndef TMPGOOD_H_
|
||||||
#define TMPGOOD_H_
|
#define TMPGOOD_H_
|
||||||
|
|
||||||
void tmpgood_configure_port_pins(void)
|
void tmpgood_configure_port_pins(void);
|
||||||
bool tmpgood_get_state(void)
|
_Bool tmpgood_get_state(void);
|
||||||
|
|
||||||
#endif /* TMPGOOD_H_ */
|
#endif /* TMPGOOD_H_ */
|
||||||
|
|
@ -9,6 +9,6 @@
|
||||||
#ifndef WS2812_H_
|
#ifndef WS2812_H_
|
||||||
#define WS2812_H_
|
#define WS2812_H_
|
||||||
|
|
||||||
void ws2812_configure_port_pins(void)
|
void ws2812_configure_port_pins(void);
|
||||||
|
|
||||||
#endif /* WS2812_H_ */
|
#endif /* WS2812_H_ */
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* adc.c
|
||||||
|
*
|
||||||
|
* Created: 03.01.2021 23:33:58
|
||||||
|
* Author: Lexus
|
||||||
|
*/
|
||||||
|
#include "adc_user.h"
|
||||||
|
#include "adc.h"
|
||||||
|
struct adc_module adc_instance;
|
||||||
|
// init ADC
|
||||||
|
void configure_adc(void)
|
||||||
|
{
|
||||||
|
struct adc_config config_adc;
|
||||||
|
adc_get_config_defaults(&config_adc);
|
||||||
|
|
||||||
|
config_adc.positive_input = ADC_POSITIVE_INPUT_PIN1;
|
||||||
|
config_adc.negative_input = ADC_NEGATIVE_INPUT_GND;
|
||||||
|
config_adc.reference = ADC_REFERENCE_INTVCC0;
|
||||||
|
|
||||||
|
config_adc.resolution = ADC_RESOLUTION_12BIT;
|
||||||
|
config_adc.gain_factor = ADC_GAIN_FACTOR_1X;
|
||||||
|
config_adc.gain_factor = ADC_GAIN_FACTOR_DIV2;
|
||||||
|
config_adc.clock_prescaler = ADC_CLOCK_PRESCALER_DIV512; // prescaler influence to accuracy of measures. Don't set less then 32
|
||||||
|
|
||||||
|
adc_init(&adc_instance, ADC, &config_adc);
|
||||||
|
|
||||||
|
adc_enable(&adc_instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t adc_read_value(void){
|
||||||
|
adc_start_conversion(&adc_instance);
|
||||||
|
uint16_t result;
|
||||||
|
do {
|
||||||
|
/* Wait for conversion to be done and read out result */
|
||||||
|
} while (adc_read(&adc_instance, &result) == STATUS_BUSY);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t adc_read_value_spec(ADC_chan_t chan)
|
||||||
|
{
|
||||||
|
adc_set_positive_input(&adc_instance, chan);
|
||||||
|
return adc_read_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
float adc_get_Q(uint16_t value){
|
||||||
|
float gane_factor=0.5;
|
||||||
|
float vref_k=1.0/1.48;
|
||||||
|
float ADC_range = 4096.0;
|
||||||
|
return (value*vref_k)/(gane_factor*ADC_range);
|
||||||
|
}
|
||||||
|
|
||||||
|
float adc_get_V(uint16_t value){
|
||||||
|
float Uvcc=3.3;
|
||||||
|
return adc_get_Q(value) * Uvcc;
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#ifndef ADC_H_
|
#ifndef ADC_H_
|
||||||
#define ADC_H_
|
#define ADC_H_
|
||||||
|
#include <stdint-gcc.h>
|
||||||
#define chan_NTC_MCU ADC_POSITIVE_INPUT_PIN1
|
#define chan_NTC_MCU ADC_POSITIVE_INPUT_PIN1
|
||||||
#define chan_NTC_TEC ADC_POSITIVE_INPUT_PIN5
|
#define chan_NTC_TEC ADC_POSITIVE_INPUT_PIN5
|
||||||
#define chan_LFB ADC_POSITIVE_INPUT_PIN19
|
#define chan_LFB ADC_POSITIVE_INPUT_PIN19
|
||||||
|
|
@ -19,10 +19,10 @@
|
||||||
|
|
||||||
typedef enum adc_positive_input ADC_chan_t;
|
typedef enum adc_positive_input ADC_chan_t;
|
||||||
|
|
||||||
void configure_adc(void)
|
void configure_adc(void);
|
||||||
uint16_t adc_read_value(void)
|
uint16_t adc_read_value(void);
|
||||||
float adc_get_V(uint16_t value)
|
float adc_get_V(uint16_t value);
|
||||||
float adc_get_Q(uint16_t value)
|
float adc_get_Q(uint16_t value);
|
||||||
uint16_t adc_read_value_spec(ADC_chan_t);
|
uint16_t adc_read_value_spec(ADC_chan_t);
|
||||||
float adc_get_V_spec(ADC_chan_t chan);
|
float adc_get_V_spec(ADC_chan_t chan);
|
||||||
#endif /* ADC_H_ */
|
#endif /* ADC_H_ */
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
* Created: 04.01.2021 0:51:07
|
* Created: 04.01.2021 0:51:07
|
||||||
* Author: Lexus
|
* Author: Lexus
|
||||||
*/
|
*/
|
||||||
|
#include <dac.h>
|
||||||
#include "dac_user.h"
|
#include "dac_user.h"
|
||||||
struct dac_module dac_instance;
|
struct dac_module dac_instance;
|
||||||
void configure_dac_channel(void)
|
void configure_dac_channel(void)
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
* Author: Lexus
|
* Author: Lexus
|
||||||
*/
|
*/
|
||||||
#include "realsence.h"
|
#include "realsence.h"
|
||||||
|
#include "port.h"
|
||||||
|
#include "conf_board.h"
|
||||||
bool rs_power;
|
bool rs_power;
|
||||||
|
|
||||||
void rs_configure_port_pins(void)
|
void rs_configure_port_pins(void)
|
||||||
|
|
@ -16,7 +18,7 @@ void rs_configure_port_pins(void)
|
||||||
port_pin_set_config(PIN_RS_POWER, &config_port_pin);
|
port_pin_set_config(PIN_RS_POWER, &config_port_pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rs_set(bool value){
|
void rs_set(_Bool value){
|
||||||
port_pin_set_output_level(PIN_RS_POWER, value?0:1);
|
port_pin_set_output_level(PIN_RS_POWER, value?0:1);
|
||||||
rs_power = value;
|
rs_power = value;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
* Created: 03.01.2021 23:22:04
|
* Created: 03.01.2021 23:22:04
|
||||||
* Author: Lexus
|
* Author: Lexus
|
||||||
*/
|
*/
|
||||||
|
#include "conf_board.h"
|
||||||
|
#include "port.h"
|
||||||
void tmpgood_configure_port_pins(void)
|
void tmpgood_configure_port_pins(void)
|
||||||
{
|
{
|
||||||
struct port_config config_port_pin;
|
struct port_config config_port_pin;
|
||||||
|
|
@ -13,7 +15,7 @@ void tmpgood_configure_port_pins(void)
|
||||||
port_pin_set_config(TC_TMPGD, &config_port_pin);
|
port_pin_set_config(TC_TMPGD, &config_port_pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tmpgood_get_state(void)
|
_Bool tmpgood_get_state(void)
|
||||||
{
|
{
|
||||||
return port_pin_get_input_level(TC_TMPGD);
|
return port_pin_get_input_level(TC_TMPGD);
|
||||||
}
|
}
|
||||||
|
|
@ -4,6 +4,9 @@
|
||||||
* Created: 03.01.2021 23:00:57
|
* Created: 03.01.2021 23:00:57
|
||||||
* Author: Lexus
|
* Author: Lexus
|
||||||
*/
|
*/
|
||||||
|
#include "ws2812.h"
|
||||||
|
#include "conf_board.h"
|
||||||
|
#include "port.h"
|
||||||
|
|
||||||
void ws2812_configure_port_pins(void)
|
void ws2812_configure_port_pins(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue