From: Xavier L. <Ba...@us...> - 2010-05-23 14:51:09
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via 217a9ec1d740143de8973a71ffbe35d58dfca212 (commit) from 804d30b9270027e496e3c21627314b14901e95f6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 217a9ec1d740143de8973a71ffbe35d58dfca212 Author: Xavier Lagorce <Xav...@cr...> Date: Sun May 23 16:50:36 2010 +0200 Added a function to get an ADC sample ----------------------------------------------------------------------- Changes: diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/watch_adc.c b/elec/boards/MotherBoard_KrobotJr2010/Firmware/watch_adc.c index af02c0c..0968153 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/watch_adc.c +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/watch_adc.c @@ -6,9 +6,10 @@ #include "watch_adc.h" #define ADC_GRP1_NUM_CHANNELS 8 -#define ADC_GRP1_BUF_DEPTH 16 +#define ADC_GRP1_BUF_DEPTH 3 static adcsample_t samples[ADC_GRP1_NUM_CHANNELS * ADC_GRP1_BUF_DEPTH]; +static adcsample_t *curBuffer; static Thread *adctp; static uint16_t compHigh[8] = {4096, 4096, 4096, 4096, 4096, 4096, 4096, 4096}; @@ -40,6 +41,8 @@ static void adccallback(adcsample_t *buffer, size_t n) { (void)n; + curBuffer = buffer; + for (i=0; i < 8; i++) { if (alarmActi[i]) { if (ind[i] == 0 && buffer[i] >= compHigh[i]) { @@ -99,3 +102,9 @@ void adcSetAlarm(uint8_t adc, uint16_t histLow, uint16_t histHigh) { void adcResetAlarm(uint8_t adc) { alarmActi[adc] = 0; } + +adcsample_t adcGetSample(uint8_t adc) { + if (adc > 7) + return 0; + return curBuffer[adc]; +} diff --git a/elec/boards/MotherBoard_KrobotJr2010/Firmware/watch_adc.h b/elec/boards/MotherBoard_KrobotJr2010/Firmware/watch_adc.h index 650acc7..e4cea30 100644 --- a/elec/boards/MotherBoard_KrobotJr2010/Firmware/watch_adc.h +++ b/elec/boards/MotherBoard_KrobotJr2010/Firmware/watch_adc.h @@ -25,5 +25,6 @@ EventSource adcAlarmWarn[8], adcAlarmOK[8]; void adcWatchInit(void); void adcSetAlarm(uint8_t adc, uint16_t histLow, uint16_t histHigh); void adcResetAlarm(uint8_t adc); +adcsample_t adcGetSample(uint8_t adc); #endif hooks/post-receive -- krobot |