Updated TFC library to be compatible with the recent hardware changes. Currently only CCD1, Servo1, Motor1, and Motor2 are interfaced.

Dependencies:   mbed

Dependents:   TFC-TEST_UPDATED_HW

Fork of FRDM-TFC by Eli Hughes

Committer:
alejandroRL
Date:
Fri Jan 12 18:22:35 2018 +0000
Revision:
9:9c61b6ebc028
Parent:
3:23cce037011f
Updated TFC library to be compatible with the new hardware changes.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emh203 1:6f37253dab87 1
emh203 1:6f37253dab87 2 #include "mbed.h"
emh203 1:6f37253dab87 3
emh203 1:6f37253dab87 4 /** @file test.h*/
emh203 1:6f37253dab87 5
emh203 1:6f37253dab87 6 /**
emh203 1:6f37253dab87 7 * @defgroup FRDM-TFC_API FRDM-TFC_API
emh203 1:6f37253dab87 8 *
emh203 1:6f37253dab87 9 * @{
emh203 1:6f37253dab87 10 */
emh203 1:6f37253dab87 11
emh203 1:6f37253dab87 12
emh203 1:6f37253dab87 13 /**
emh203 1:6f37253dab87 14
emh203 1:6f37253dab87 15 @addtogroup FRDM-TFC_API
emh203 1:6f37253dab87 16
emh203 1:6f37253dab87 17 @{
emh203 1:6f37253dab87 18
emh203 1:6f37253dab87 19 Resources used by the TFC Library\n
emh203 1:6f37253dab87 20
emh203 1:6f37253dab87 21 I/O:\n
emh203 1:6f37253dab87 22 -------------------------------------------------------------------------------------------------\n
emh203 1:6f37253dab87 23
alejandroRL 9:9c61b6ebc028 24 PTA12 Servo 1\n
alejandroRL 9:9c61b6ebc028 25 PTA13 Servo 2\n
emh203 1:6f37253dab87 26 \n
emh203 1:6f37253dab87 27 \n
alejandroRL 9:9c61b6ebc028 28 PTB8 (Camera CCD1 SI)\n
alejandroRL 9:9c61b6ebc028 29 PTB9 (Camera CCD1 CLK)\n
alejandroRL 9:9c61b6ebc028 30 PTC2 (Camera CCD1 A0)\n
alejandroRL 9:9c61b6ebc028 31 \n
emh203 1:6f37253dab87 32
alejandroRL 9:9c61b6ebc028 33 PTA4 Motor1 PWM1 FTM0_CH1\n
alejandroRL 9:9c61b6ebc028 34 PTA5 Motor1 PWM2 FTM0_CH2\n
alejandroRL 9:9c61b6ebc028 35 PTC8 Motor2 PWM1 FTM0_CH4\n
alejandroRL 9:9c61b6ebc028 36 PTC9 Motor2 PWM2 FTM0_CH5\n
emh203 1:6f37253dab87 37 }
emh203 1:6f37253dab87 38 */
emh203 1:6f37253dab87 39
emh203 1:6f37253dab87 40
emh203 1:6f37253dab87 41
emh203 1:6f37253dab87 42 #ifndef _TFC_H
emh203 1:6f37253dab87 43 #define _TFC_H
emh203 1:6f37253dab87 44
alejandroRL 9:9c61b6ebc028 45 #define TAOS_CLK_HIGH PTB->PSOR = (1<<9)
alejandroRL 9:9c61b6ebc028 46 #define TAOS_CLK_LOW PTB->PCOR = (1<<9)
alejandroRL 9:9c61b6ebc028 47 #define TAOS_SI_HIGH PTB->PSOR = (1<<8)
alejandroRL 9:9c61b6ebc028 48 #define TAOS_SI_LOW PTB->PCOR = (1<<8)
emh203 1:6f37253dab87 49
emh203 1:6f37253dab87 50
emh203 1:6f37253dab87 51 /**
emh203 1:6f37253dab87 52
emh203 1:6f37253dab87 53 @addtogroup FRDM-TFC_API
emh203 1:6f37253dab87 54 @{
emh203 1:6f37253dab87 55 */
emh203 1:6f37253dab87 56
emh203 1:6f37253dab87 57 /** Initialized the TFC API. Call before using any other API calls.
emh203 1:6f37253dab87 58 *
emh203 1:6f37253dab87 59 */
emh203 1:6f37253dab87 60 void TFC_Init();
emh203 1:6f37253dab87 61
emh203 1:6f37253dab87 62 /** ServoTicker will increment once every servo cycle.
emh203 1:6f37253dab87 63 * It can be used to synchronize events to the start of a servo cycle. ServoTicker is a volatile uint32_t and is updated in the TPM1 overlflow interrupt. This means you will see ServoTicker increment on the rising edge of the servo PWM signal
emh203 1:6f37253dab87 64 *
emh203 1:6f37253dab87 65 */
emh203 1:6f37253dab87 66 extern volatile uint32_t TFC_ServoTicker;
emh203 1:6f37253dab87 67
emh203 1:6f37253dab87 68
emh203 1:6f37253dab87 69 /** Sets the servo channels
emh203 1:6f37253dab87 70 *
emh203 1:6f37253dab87 71 * @param ServoNumber Which servo channel on the FRDM-TFC to use (0 or 1). 0 is the default channel for steering
emh203 1:6f37253dab87 72 * @param Position Angle setting for servo in a normalized (-1.0 to 1.0) form. The range of the servo can be changed with the InitServos function.
emh203 1:6f37253dab87 73 * This is called in the TFC constructor with some useful default values--> 20mSec period, 0.5mS min and 2.0mSec max. you may need to adjust these for your own particular setup.
emh203 1:6f37253dab87 74 */
emh203 1:6f37253dab87 75 void TFC_SetServo(uint8_t ServoNumber, float Position);
emh203 1:6f37253dab87 76
emh203 1:6f37253dab87 77 /** Initializes TPM for the servoes. It also sets the max and min ranges
emh203 1:6f37253dab87 78 *
emh203 1:6f37253dab87 79 * @param ServoPulseWidthMin Minimum pulse width (in seconds) for the servo. The value of -1.0 in SetServo is mapped to this pulse width. I.E. .001
emh203 1:6f37253dab87 80 * @param ServoPulseWidthMax Maximum pulse width (in seconds) for the servo. The value of +1.0 in SetServo is mapped to this pulse width. I.E. .002
emh203 1:6f37253dab87 81 * @param ServoPeriod Period of the servo pulses (in seconds). I.e. .020 for 20mSec
emh203 1:6f37253dab87 82 */
emh203 1:6f37253dab87 83
emh203 1:6f37253dab87 84 void TFC_InitServos(float ServoPulseWidthMin, float ServoPulseWidthMax, float ServoPeriod);
emh203 1:6f37253dab87 85
emh203 1:6f37253dab87 86
emh203 1:6f37253dab87 87 /** Initialized TPM0 to be used for generating PWM signals for the the dual drive motors. This method is called in the TFC constructor with a default value of 4000.0Hz
emh203 1:6f37253dab87 88 *
emh203 1:6f37253dab87 89 * @param SwitchingFrequency PWM Switching Frequency in floating point format. Pick something between 1000 and 9000. Maybe you can modulate it and make a tune.
emh203 1:6f37253dab87 90 */
emh203 1:6f37253dab87 91 void TFC_InitMotorPWM(float SwitchingFrequency);
emh203 1:6f37253dab87 92
emh203 1:6f37253dab87 93 /** Sets the PWM value for each motor.
emh203 1:6f37253dab87 94 *
emh203 1:6f37253dab87 95 * @param MotorA The PWM value for HBridgeA. The value is normalized to the floating point range of -1.0 to +1.0. -1.0 is 0% (Full Reverse on the H-Bridge) and 1.0 is 100% (Full Forward on the H-Bridge)
emh203 1:6f37253dab87 96 * @param MotorB The PWM value for HBridgeB. The value is normalized to the floating point range of -1.0 to +1.0. -1.0 is 0% (Full Reverse on the H-Bridge) and 1.0 is 100% (Full Forward on the H-Bridge)
emh203 1:6f37253dab87 97 */
emh203 1:6f37253dab87 98 void TFC_SetMotorPWM(float MotorA ,float MotorB);
emh203 1:6f37253dab87 99
emh203 3:23cce037011f 100
emh203 1:6f37253dab87 101 /** Pointer to two channels of line scan camera data. Each channel is 128 points of uint8_t's. Note that the underlying implementation is ping-pong buffer These pointers will point to the
emh203 1:6f37253dab87 102 *inactive buffer.
emh203 1:6f37253dab87 103 *
emh203 1:6f37253dab87 104 */
emh203 1:6f37253dab87 105
emh203 3:23cce037011f 106 extern volatile uint16_t * TFC_LineScanImage0;
emh203 3:23cce037011f 107 extern volatile uint16_t * TFC_LineScanImage1;
emh203 3:23cce037011f 108
emh203 1:6f37253dab87 109
emh203 1:6f37253dab87 110 /** This flag will increment when a new frame is ready. Check for a non zero value (and reset to zero!) when you want to read the camera(s)
emh203 1:6f37253dab87 111 *
emh203 1:6f37253dab87 112 */
emh203 1:6f37253dab87 113
emh203 3:23cce037011f 114 extern volatile uint8_t TFC_LineScanImageReady;
emh203 3:23cce037011f 115
emh203 1:6f37253dab87 116 /** @} */
emh203 1:6f37253dab87 117
emh203 1:6f37253dab87 118
emh203 1:6f37253dab87 119 #endif