![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Updated TFC library to be compatible with the recent hardware changes. Currently only CCD1, Servo1, Motor1, and Motor2 are interfaced.
Dependents: TFC-TEST_UPDATED_HW
Fork of FRDM-TFC by
Diff: TFC.cpp
- Revision:
- 3:23cce037011f
- Parent:
- 1:6f37253dab87
- Child:
- 7:b34924a05d60
- Child:
- 8:24430a0d7fd8
- Child:
- 9:9c61b6ebc028
--- a/TFC.cpp Wed Jul 17 19:31:32 2013 +0000 +++ b/TFC.cpp Thu Aug 15 23:26:19 2013 +0000 @@ -332,7 +332,6 @@ volatile uint16_t QueuedServo0Val; volatile uint16_t QueuedServo1Val; -volatile uint8_t TFC_LineScanDataReady; volatile uint16_t *LineScanImage0WorkingBuffer; volatile uint16_t *LineScanImage1WorkingBuffer; @@ -340,13 +339,17 @@ volatile uint16_t LineScanImage1Buffer[2][128]; volatile uint8_t LineScanWorkingBuffer; +volatile uint16_t * TFC_LineScanImage0; +volatile uint16_t * TFC_LineScanImage1; +volatile uint8_t TFC_LineScanImageReady; + volatile uint16_t PotADC_Value[2]; volatile uint16_t BatSenseADC_Value; volatile uint16_t CurrentADC_State; volatile uint8_t CurrentLineScanPixel; volatile uint8_t CurrentLineScanChannel; volatile uint32_t TFC_ServoTicker; -volatile uint16_t * TFC_LineScanCameraData[2]; + void TFC_SetServoDutyCycle(uint8_t ServoNumber, float DutyCycle); void TFC_InitLineScanCamera(); @@ -564,7 +567,7 @@ void TFC_SetServo(uint8_t ServoNumber, float Position) { TFC_SetServoDutyCycle(ServoNumber , - ((Position + 1.0)/2) * ((_ServoDutyCycleMax - _ServoDutyCycleMin)+_ServoDutyCycleMin) ); + ((Position + 1.0)/2) * ((_ServoDutyCycleMax - _ServoDutyCycleMin))+_ServoDutyCycleMin) ; } @@ -852,18 +855,18 @@ LineScanImage0WorkingBuffer = &LineScanImage0Buffer[1][0]; LineScanImage1WorkingBuffer = &LineScanImage1Buffer[1][0]; - TFC_LineScanCameraData[0] = &LineScanImage0Buffer[0][0]; - TFC_LineScanCameraData[1] = &LineScanImage1Buffer[0][0]; + TFC_LineScanImage0 = &LineScanImage0Buffer[0][0]; + TFC_LineScanImage1 = &LineScanImage1Buffer[0][0]; } else { LineScanWorkingBuffer = 0; LineScanImage0WorkingBuffer = &LineScanImage0Buffer[0][0]; LineScanImage1WorkingBuffer = &LineScanImage1Buffer[0][0]; - TFC_LineScanCameraData[0] = &LineScanImage0Buffer[1][0]; - TFC_LineScanCameraData[1] = &LineScanImage1Buffer[1][0]; + TFC_LineScanImage0 = &LineScanImage0Buffer[1][0]; + TFC_LineScanImage1 = &LineScanImage1Buffer[1][0]; } - TFC_LineScanDataReady++; + TFC_LineScanImageReady++; } break; @@ -892,8 +895,8 @@ LineScanImage0WorkingBuffer = &LineScanImage0Buffer[LineScanWorkingBuffer][0]; LineScanImage1WorkingBuffer = &LineScanImage1Buffer[LineScanWorkingBuffer][0]; - TFC_LineScanCameraData[0] = &LineScanImage0Buffer[1][0]; - TFC_LineScanCameraData[1] = &LineScanImage1Buffer[1][0]; + TFC_LineScanImage0 = &LineScanImage0Buffer[1][0]; + TFC_LineScanImage1 = &LineScanImage1Buffer[1][0]; } @@ -908,12 +911,11 @@ { //Clock Setup for the TPM requires a couple steps. - //1st, set the clock mux //See Page 124 of f the KL25 Sub-Family Reference Manual, Rev. 3, September 2012 - // SIM->SOPT2 |= SIM_SOPT2_PLLFLLSEL_MASK;// We Want MCGPLLCLK/2 (See Page 196 of the KL25 Sub-Family Reference Manual, Rev. 3, September 2012) - // SIM->SOPT2 &= ~(SIM_SOPT2_TPMSRC_MASK); - // SIM->SOPT2 |= SIM_SOPT2_TPMSRC(1); //We want the MCGPLLCLK/2 (See Page 196 of the KL25 Sub-Family Reference Manual, Rev. 3, September 2012) + SIM->SOPT2 |= SIM_SOPT2_PLLFLLSEL_MASK;// We Want MCGPLLCLK/2 (See Page 196 of the KL25 Sub-Family Reference Manual, Rev. 3, September 2012) + SIM->SOPT2 &= ~(SIM_SOPT2_TPMSRC_MASK); + SIM->SOPT2 |= SIM_SOPT2_TPMSRC(1); //We want the MCGPLLCLK/2 (See Page 196 of the KL25 Sub-Family Reference Manual, Rev. 3, September 2012) //Enable the Clock to the FTM0 Module @@ -988,3 +990,47 @@ { return (((float)BatSenseADC_Value/(float)(ADC_MAX_CODE)) * 3.0);// * ((47000.0+10000.0)/10000.0); } + + +void TFC_SetBatteryLED_Level(uint8_t BattLevel) +{ + switch(BattLevel) + { + default: + case 0: + TFC_BAT_LED0_OFF; + TFC_BAT_LED1_OFF; + TFC_BAT_LED2_OFF; + TFC_BAT_LED3_OFF; + break; + + case 1: + TFC_BAT_LED0_ON; + TFC_BAT_LED1_OFF; + TFC_BAT_LED2_OFF; + TFC_BAT_LED3_OFF; + break; + + case 2: + TFC_BAT_LED0_ON; + TFC_BAT_LED1_ON; + TFC_BAT_LED2_OFF; + TFC_BAT_LED3_OFF; + break; + + case 3: + TFC_BAT_LED0_ON; + TFC_BAT_LED1_ON; + TFC_BAT_LED2_ON; + TFC_BAT_LED3_OFF; + break; + + case 4: + TFC_BAT_LED0_ON; + TFC_BAT_LED1_ON; + TFC_BAT_LED2_ON; + TFC_BAT_LED3_ON; + break; + + } +}