arm Adc: Fix codeql warnings

This commit is contained in:
Philippe Teuwen 2022-02-27 15:03:54 +01:00
commit 47096906fb
2 changed files with 5 additions and 5 deletions

View file

@ -121,7 +121,7 @@ void send_wtx(uint16_t wtx) {
// in ADC units (0 to 1023). Also a routine to sum up a number of samples and // in ADC units (0 to 1023). Also a routine to sum up a number of samples and
// return that. // return that.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static uint16_t ReadAdc(int ch) { static uint16_t ReadAdc(uint8_t ch) {
// Note: ADC_MODE_PRESCALE and ADC_MODE_SAMPLE_HOLD_TIME are set to the maximum allowed value. // Note: ADC_MODE_PRESCALE and ADC_MODE_SAMPLE_HOLD_TIME are set to the maximum allowed value.
// AMPL_HI is are high impedance (10MOhm || 1MOhm) output, the input capacitance of the ADC is 12pF (typical). This results in a time constant // AMPL_HI is are high impedance (10MOhm || 1MOhm) output, the input capacitance of the ADC is 12pF (typical). This results in a time constant
@ -147,11 +147,11 @@ static uint16_t ReadAdc(int ch) {
} }
// was static - merlok // was static - merlok
uint16_t AvgAdc(int ch) { uint16_t AvgAdc(uint8_t ch) {
return SumAdc(ch, 32) >> 5; return SumAdc(ch, 32) >> 5;
} }
uint16_t SumAdc(int ch, int NbSamples) { uint16_t SumAdc(uint8_t ch, uint8_t NbSamples) {
uint16_t a = 0; uint16_t a = 0;
for (uint8_t i = 0; i < NbSamples; i++) for (uint8_t i = 0; i < NbSamples; i++)
a += ReadAdc(ch); a += ReadAdc(ch);

View file

@ -44,8 +44,8 @@ void send_wtx(uint16_t wtx);
void ReadMem(int addr); void ReadMem(int addr);
void __attribute__((noreturn)) AppMain(void); void __attribute__((noreturn)) AppMain(void);
uint16_t AvgAdc(int ch); uint16_t AvgAdc(uint8_t ch);
uint16_t SumAdc(int ch, int NbSamples); uint16_t SumAdc(uint8_t ch, uint8_t NbSamples);
//void PrintToSendBuffer(void); //void PrintToSendBuffer(void);
void ToSendStuffBit(int b); void ToSendStuffBit(int b);