27 #include "../../lms2012/source/lms2012.h"
28 #include "../../lms2012/source/am1808.h"
33 #define MODULE_NAME "pwm_module"
34 #define DEVICE1_NAME PWM_DEVICE
35 #define DEVICE2_NAME MOTOR_DEVICE
38 #define SOFT_TIMER_MS 2
39 #define SOFT_TIMER_SETUP (SOFT_TIMER_MS * 1000000)
44 #define NO_OF_TACHO_SAMPLES 128
45 #define NO_OF_OUTPUT_PORTS 4
47 #define MAX_PWM_CNT (10000)
48 #define MAX_SPEED (100)
49 #define SPEED_PWMCNT_REL (100) //(MAX_PWM_CNT/MAX_SPEED)
50 #define RAMP_FACTOR (1000)
51 #define MAX_SYNC_MOTORS (2)
56 #define COUNTS_PER_PULSE_LM 12800L
57 #define COUNTS_PER_PULSE_MM 8100L
74 #define TB_COUNT_UP 0x0 // TBCNT MODE bits
75 #define TB_COUNT_FREEZE 0x3 // TBCNT MODE bits
76 #define TB_DISABLE 0x0 // PHSEN bit
78 #define TB_SHADOW 0x0 // PRDLD bit
79 #define TB_IMMEDIATE 0x8
80 #define TB_SYNC_DISABLE 0x30 // SYNCOSEL bits
81 #define TB_HDIV1 0x0 // HSPCLKDIV bits
82 #define TB_DIV1 0x0 // CLKDIV bits
83 #define TB_UP 0x2000 // PHSDIR bit
87 #define CC_CTR_A_ZERO 0x0 // LOADAMODE bits
88 #define CC_CTR_B_ZERO 0x0
89 #define CC_A_SHADOW 0x00 // SHDWAMODE and SHDWBMODE bits
90 #define CC_B_SHADOW 0x00
262 static int ModuleInit(
void);
263 static void ModuleExit(
void);
265 static irqreturn_t IntA (
int irq,
void * dev);
266 static irqreturn_t IntB (
int irq,
void * dev);
267 static irqreturn_t IntC (
int irq,
void * dev);
268 static irqreturn_t IntD (
int irq,
void * dev);
281 #include <linux/kernel.h>
282 #include <linux/fs.h>
283 #include <linux/signal.h>
284 #include <linux/sched.h>
287 #include <linux/ioport.h>
288 #include <asm/gpio.h>
289 #include <asm/uaccess.h>
290 #include <linux/module.h>
291 #include <linux/miscdevice.h>
293 #include <linux/mm.h>
294 #include <linux/hrtimer.h>
296 #include <linux/init.h>
297 #include <asm/siginfo.h>
298 #include <linux/rcupdate.h>
299 #include <linux/uaccess.h>
300 #include <linux/debugfs.h>
303 #include <asm/uaccess.h>
305 #include <linux/irq.h>
306 #include <linux/interrupt.h>
316 #include <mach/mux.h>
336 #define IRQA_PINNO ((pOutputPortPin[Hw])[(0 * OUTPUT_PORT_PINS) + INT].Pin)
337 #define IRQB_PINNO ((pOutputPortPin[Hw])[(1 * OUTPUT_PORT_PINS) + INT].Pin)
338 #define IRQC_PINNO ((pOutputPortPin[Hw])[(2 * OUTPUT_PORT_PINS) + INT].Pin)
339 #define IRQD_PINNO ((pOutputPortPin[Hw])[(3 * OUTPUT_PORT_PINS) + INT].Pin)
471 [
EP2] = (
INPIN*)&EP2_OutputPortPin[0],
475 #define OutputReadDir(port,pin) ((HwInvBits ^ (*pOutputPortPin[Hw][(port * OUTPUT_PORT_PINS) + pin].pGpio).in_data) & pOutputPortPin[Hw][(port * OUTPUT_PORT_PINS) + pin].Mask)
476 #define READDirA OutputReadDir(0,DIR)
477 #define READDirB OutputReadDir(1,DIR)
478 #define READDirC OutputReadDir(2,DIR)
479 #define READDirD OutputReadDir(3,DIR)
485 static ULONG *SYSCFG0;
486 static ULONG *SYSCFG1;
489 static UWORD *eHRPWM1;
492 static ULONG *TIMER64P3;
502 static UBYTE ReadyStatus = 0;
503 static UBYTE TestStatus = 0;
512 static SBYTE MaxSyncSpeed;
514 static struct hrtimer Device1Timer;
515 static ktime_t Device1Time;
544 static UBYTE *SamplesPerSpeed[
NO_OF_OUTPUT_PORTS] = {SamplesLargeMotor, SamplesLargeMotor, SamplesLargeMotor, SamplesLargeMotor};
553 #define FLOATFaultPins {\
554 if (((pOutputPortPin[Hw])[(0 * OUTPUT_PORT_PINS) + FAULT].Pin) != -1)\
556 (*pOutputPortPin[Hw][(0 * OUTPUT_PORT_PINS) + FAULT].pGpio).dir |= pOutputPortPin[Hw][(0 * OUTPUT_PORT_PINS) + FAULT].Mask;\
558 if (((pOutputPortPin[Hw])[(2 * OUTPUT_PORT_PINS) + FAULT].Pin) != -1)\
560 (*pOutputPortPin[Hw][(2 * OUTPUT_PORT_PINS) + FAULT].pGpio).dir |= pOutputPortPin[Hw][(2 * OUTPUT_PORT_PINS) + FAULT].Mask;\
564 #define SETSleepPins {\
565 if (((pOutputPortPin[Hw])[(0 * OUTPUT_PORT_PINS) + SLEEP].Pin) != -1)\
567 (*pOutputPortPin[Hw][(0 * OUTPUT_PORT_PINS) + SLEEP].pGpio).set_data = pOutputPortPin[Hw][(0 * OUTPUT_PORT_PINS) + SLEEP].Mask;\
568 (*pOutputPortPin[Hw][(0 * OUTPUT_PORT_PINS) + SLEEP].pGpio).dir &= ~pOutputPortPin[Hw][(0 * OUTPUT_PORT_PINS) + SLEEP].Mask;\
570 if (((pOutputPortPin[Hw])[(2 * OUTPUT_PORT_PINS) + SLEEP].Pin) != -1)\
572 (*pOutputPortPin[Hw][(2 * OUTPUT_PORT_PINS) + SLEEP].pGpio).set_data = pOutputPortPin[Hw][(2 * OUTPUT_PORT_PINS) + SLEEP].Mask;\
573 (*pOutputPortPin[Hw][(2 * OUTPUT_PORT_PINS) + SLEEP].pGpio).dir &= ~pOutputPortPin[Hw][(2 * OUTPUT_PORT_PINS) + SLEEP].Mask;\
577 #define SETMotorType(Port, NewType) {\
578 Motor[Port].Type = NewType;\
579 if (TYPE_MINITACHO == NewType)\
581 CountsPerPulse[Port] = COUNTS_PER_PULSE_MM;\
582 SamplesPerSpeed[Port] = SamplesMediumMotor;\
586 CountsPerPulse[Port] = COUNTS_PER_PULSE_LM;\
587 SamplesPerSpeed[Port] = SamplesLargeMotor;\
591 #define SETAvgTachoCount(Port, Speed) {\
594 AVG_TACHO_COUNTS[Port] = SamplesPerSpeed[Port][3];\
595 AVG_COUNTS[Port] = SamplesPerSpeed[Port][3] * CountsPerPulse[Port];\
601 AVG_TACHO_COUNTS[Port] = SamplesPerSpeed[Port][2];\
602 AVG_COUNTS[Port] = SamplesPerSpeed[Port][2] * CountsPerPulse[Port];\
608 AVG_TACHO_COUNTS[Port] = SamplesPerSpeed[Port][1];\
609 AVG_COUNTS[Port] = SamplesPerSpeed[Port][1] * CountsPerPulse[Port];\
613 AVG_TACHO_COUNTS[Port] = SamplesPerSpeed[Port][0];\
614 AVG_COUNTS[Port] = SamplesPerSpeed[Port][0] * CountsPerPulse[Port];\
620 #define FREERunning24bittimer ((ULONG)((((ULONG*)(TIMER64P3))[TIM34])>>8))
622 #define CLEARTachoArray(No) {\
623 Motor[No].DirChgPtr = 0;\
624 memset(&TachoSamples[No], 0, sizeof(TACHOSAMPLES));\
627 #define OutputFloat(port,pin) {\
628 (*pOutputPortPin[Hw][(port * OUTPUT_PORT_PINS) + pin].pGpio).dir |= pOutputPortPin[Hw][(port * OUTPUT_PORT_PINS) + pin].Mask;\
631 #define OutputRead(port,pin) ((*pOutputPortPin[Hw][(port * OUTPUT_PORT_PINS) + pin].pGpio).in_data & pOutputPortPin[Hw][(port * OUTPUT_PORT_PINS) + pin].Mask)
633 #define OutputHigh(port,pin) {\
634 (*pOutputPortPin[Hw][(port * OUTPUT_PORT_PINS) + pin].pGpio).set_data = pOutputPortPin[Hw][(port * OUTPUT_PORT_PINS) + pin].Mask;\
635 (*pOutputPortPin[Hw][(port * OUTPUT_PORT_PINS) + pin].pGpio).dir &= ~pOutputPortPin[Hw][(port * OUTPUT_PORT_PINS) + pin].Mask;\
638 #define OutputLow(port,pin) {\
639 (*pOutputPortPin[Hw][(port * OUTPUT_PORT_PINS) + pin].pGpio).clr_data = pOutputPortPin[Hw][(OUTPUT_PORT_PINS * port) + pin].Mask;\
640 (*pOutputPortPin[Hw][(port * OUTPUT_PORT_PINS) + pin].pGpio).dir &= ~pOutputPortPin[Hw][(OUTPUT_PORT_PINS * port) + pin].Mask;\
644 #define EHRPWMClkDis {\
645 eHRPWM1[TBCTL] = (TB_UP | TB_DISABLE | TB_SHADOW | TB_SYNC_DISABLE | TB_HDIV1 | TB_DIV1 | TB_COUNT_FREEZE);\
648 #define EHRPWMClkEna {\
649 eHRPWM1[TBCTL] = (TB_UP | TB_DISABLE | TB_SHADOW | TB_SYNC_DISABLE | TB_HDIV1 | TB_DIV1 | TB_COUNT_UP);\
651 iowrite32((ioread32(&SYSCFG0[CFGCHIP1]) | TBCLKSYNC),&SYSCFG0[CFGCHIP1]); \
656 iowrite16(0x00, &eCAP0[0x15]);\
657 iowrite16(0x00, &eCAP1[0x15]);\
658 TIMER64P3[TGCR] = 0x00000000;\
659 iowrite16(0x00, &eHRPWM1[TBCTL]);\
660 iowrite16(0x00, &eHRPWM1[CMPCTL]);\
664 #define SETPwmFreqKHz(KHz) {\
665 eHRPWM1[TBPRD] = KHz; \
670 #define SETUPPwmModules { \
676 eHRPWM1[CMPCTL] = (CC_A_SHADOW | CC_B_SHADOW | CC_CTR_A_ZERO | CC_CTR_B_ZERO);\
677 eHRPWM1[AQCTLA] = 0x00000021;\
678 eHRPWM1[AQCTLB] = 0x00000201;\
684 (eCAP0)[CTRPHS] = 0;\
685 (eCAP1)[CTRPHS] = 0;\
686 eCAP0[ECCTL2] = 0x0690;\
687 eCAP1[ECCTL2] = 0x0690;\
688 TIMER64P3[TGCR] = 0x00003304;\
689 TIMER64P3[TGCR] |= 0x00000002;\
690 TIMER64P3[PRD34] = 0xFFFFFFFF;\
691 TIMER64P3[TCR] = 0x00800000;\
698 SETPwmFreqKHz(MAX_PWM_CNT-1);\
703 #define READIntA OutputRead(0,INT)
704 #define READIntB OutputRead(1,INT)
705 #define READIntC OutputRead(2,INT)
706 #define READIntD OutputRead(3,INT)
729 if ((Param1 * Inv) < (Param2 * Inv))
755 if ((
NON_INV == Dir) && (0 < *pSpeed))
761 if ((
INV == Dir) && (0 > *pSpeed))
811 Motor[Port].
Power = Power;
816 Motor[Port].
Power = Power;
833 Power = ((Power * 8000)/10000) + 2000;
850 Power = ((Power * 9500)/10000) + 500;
853 SetDuty[Port](Power);
862 Motor[Port].
Power = Power;
867 Motor[Port].
Power = Power;
884 Power = ((Power * 9000)/10000) + 1000;
901 Power = ((Power * 10000)/10000) + 0;
904 SetDuty[Port](Power);
953 *StepPowerSteps[No] -= AdjustTachoValue;
955 if (Motor[No].TargetBrake)
957 if (StepPowerSteps[No] != &(Motor[No].TachoCnt))
972 if (SyncMNos[0] == No)
976 if (SyncMNos[1] == No)
980 ReadyStatus &= ~(0x01 << No);
981 TestStatus &= ~(0x01 << No);
1006 if (Motor[No].TachoCntUp)
1011 if (0 != Motor[No].Speed)
1023 if (0 == Motor[No].RampUpFactor)
1029 if (0 == Motor[No].Speed)
1034 if((0 == Motor[No].TachoCntConst) && (0 == Motor[No].TachoCntDown) && (1 == Motor[No].TargetBrake))
1069 ReturnState =
FALSE;
1071 if (Motor[No].TachoCntConst)
1073 *StepPowerSteps[No] -= AdjustTachoValue;
1078 if((0 == Motor[No].TachoCntDown) && (1 == Motor[No].TargetBrake))
1089 return(ReturnState);
1111 if (Motor[No].TachoCntDown)
1115 *StepPowerSteps[No] -= AdjustTachoValue;
1117 MinRegEnabled[No] =
FALSE;
1148 if (Motor[No].TachoCntUp)
1155 if((0 == Motor[No].TachoCntConst) && (0 == Motor[No].TachoCntDown) && (1 == Motor[No].TargetBrake))
1190 ReturnState =
FALSE;
1192 if (Motor[No].TachoCntConst)
1194 *StepPowerSteps[No] -= AdjustTachoValue;
1200 if((0 == Motor[No].TachoCntDown) && (1 == Motor[No].TargetBrake))
1211 return(ReturnState);
1233 if (Motor[No].TachoCntDown)
1237 *StepPowerSteps[No] -= AdjustTachoValue;
1239 MinRegEnabled[No] =
FALSE;
1277 SpeedErr = ((
SLONG)(Motor[No].TargetSpeed) - (
SLONG)(Motor[No].Speed));
1278 Motor[No].
PVal = SpeedErr * 4;
1279 Motor[No].
IVal = ((Motor[No].
IVal * 9)/10) + (SpeedErr / 3);
1284 SpeedErr = ((
SLONG)(Motor[No].TargetSpeed) - (
SLONG)(Motor[No].Speed));
1285 Motor[No].
PVal = SpeedErr * 2;
1286 Motor[No].
IVal = ((Motor[No].
IVal * 9)/10) + (SpeedErr / 4);
1304 if (((Motor[No].TargetSpeed) > 0) && (Motor[No].Power < 0))
1306 Motor[No].
Power = 0;
1309 if (((Motor[No].TargetSpeed) < 0) && (Motor[No].Power > 0))
1311 Motor[No].
Power = 0;
1322 TmpTacho = TachoCnt * 100;
1335 Motor[No].
Power = 0 - TmpTacho;
1352 if ((Motor[No].TargetSpeed > 5) || (Motor[No].
TargetSpeed < -5))
1383 *Counts = *StepPowerSteps[No];
1385 if (
TRUE == Motor[No].BrakeAfter)
1387 if (StepPowerSteps[No] != &(Motor[No].TachoCnt))
1390 *CompareCounts = *Counts + (Motor[No].
Speed);
1397 *CompareCounts = *Counts + ((Motor[No].
Speed)/2);
1401 *CompareCounts = *Counts + ((Motor[No].
Speed/3));
1407 *CompareCounts = *Counts;
1414 ReadyStatus &= ~(0x01 << MotorNo);
1415 TestStatus &= ~(0x01 << MotorNo);
1416 Motor[MotorNo].
Power = 0;
1417 Motor[MotorNo].
Speed = 0;
1421 SetPower(MotorNo, Motor[MotorNo].Power);
1428 ReadyStatus &= ~(0x01 << MotorNo);
1429 TestStatus &= ~(0x01 << MotorNo);
1430 Motor[MotorNo].
Power = 0;
1431 Motor[MotorNo].
Speed = 0;
1435 SetPower(MotorNo, Motor[MotorNo].Power);
1442 UBYTE TmpNo0, TmpNo1;
1444 TmpNo0 = SyncMNos[0];
1445 TmpNo1 = SyncMNos[1];
1471 if (
TRUE == SyncCmd)
1474 if (((MotorBitField & (0x01 << SyncMNos[0])) && (MotorBitField & (0x01 << SyncMNos[1]))))
1486 if ((MotorBitField & (0x01 << SyncMNos[0])) || (MotorBitField & (0x01 << SyncMNos[1])))
1540 static enum hrtimer_restart Device1TimerInterrupt1(
struct hrtimer *pTimer)
1545 static SLONG volatile TmpTacho;
1546 static SLONG volatile Tmp;
1548 hrtimer_forward_now(pTimer,Device1Time);
1565 if (
FALSE == Motor[No].Mutex)
1569 switch(Motor[No].State)
1573 if (Motor[No].TargetPower != Motor[No].Power)
1601 if (StepPowerSteps[No] != &(Motor[No].TachoCnt))
1624 if (
TRUE == Motor[No].BrakeAfter)
1628 Status =
RampDownToBrake(No, StepCnt, Motor[No].TachoCntUp, Motor[No].Dir);
1649 SLONG StepCnt, StepCntTst;
1651 if (StepPowerSteps[No] != &(Motor[No].TachoCnt))
1668 if (
TRUE == Motor[No].BrakeAfter)
1689 StepCnt = *StepPowerSteps[No];
1691 if (StepPowerSteps[No] != &(Motor[No].TachoCnt))
1726 if (StepPowerSteps[No] != &(Motor[No].TachoCnt))
1739 if (0 != Motor[No].Speed)
1757 Motor[No].
Power += (20 * Motor[No].
Dir);
1765 if (
TRUE == Motor[No].BrakeAfter)
1767 Status =
RampDownToBrake(No, StepCnt, Motor[No].TachoCntUp, Motor[No].Dir);
1788 SLONG StepCnt, StepCntTst;
1790 if (StepPowerSteps[No] != &(Motor[No].TachoCnt))
1806 if (
TRUE == Motor[No].BrakeAfter)
1827 StepCnt = *StepPowerSteps[No];
1829 if (StepPowerSteps[No] != &(Motor[No].TachoCnt))
1851 MinRegEnabled[No] =
TRUE;
1871 StepCnt = *StepPowerSteps[No];
1873 if (StepPowerSteps[No] != &(Motor[No].TachoCnt))
1884 if ((Motor[SyncMNos[0]].Power > (
MAX_PWM_CNT - 100)) || (Motor[SyncMNos[0]].Power < (-
MAX_PWM_CNT + 100)))
1893 if (((Motor[SyncMNos[0]].Speed <= 0) && (Motor[SyncMNos[0]].TargetSpeed <= 0)) ||
1894 ((Motor[SyncMNos[0]].Speed >= 0) && (Motor[SyncMNos[0]].TargetSpeed >= 0)))
1896 MaxSyncSpeed = Motor[SyncMNos[0]].
Speed;
1901 if ((Motor[SyncMNos[1]].Power > (
MAX_PWM_CNT - 100)) || (Motor[SyncMNos[1]].Power < (-
MAX_PWM_CNT + 100)))
1910 if (((Motor[SyncMNos[1]].Speed <= 0) && (Motor[SyncMNos[1]].TargetSpeed <= 0)) ||
1911 ((Motor[SyncMNos[1]].Speed >= 0) && (Motor[SyncMNos[1]].TargetSpeed >= 0)))
1913 MaxSyncSpeed = Motor[SyncMNos[1]].
Speed;
1919 if (
FALSE == Status)
1924 IncSpeed(Motor[SyncMNos[0]].Dir, &MaxSyncSpeed);
1934 if (
TRUE ==
CheckLessThanSpecial(Motor[SyncMNos[1]].TachoCnt, Motor[SyncMNos[0]].TachoCnt, Motor[SyncMNos[0]].Dir))
1936 DecSpeed(Motor[SyncMNos[0]].Dir, &(Motor[SyncMNos[0]].TargetSpeed));
1939 if (
TRUE ==
CheckLessThanSpecial(Motor[SyncMNos[0]].TachoCnt, Motor[SyncMNos[1]].TachoCnt, Motor[SyncMNos[0]].Dir))
1941 DecSpeed(Motor[SyncMNos[0]].Dir, &(Motor[SyncMNos[1]].TargetSpeed));
1953 if (StepPowerSteps[No] != &(Motor[No].TachoCnt))
1968 StepCnt = *StepPowerSteps[No];
1970 if (StepPowerSteps[No] != &(Motor[No].TachoCnt))
1981 if ((Motor[SyncMNos[0]].Power > (
MAX_PWM_CNT - 100)) || (Motor[SyncMNos[0]].Power < (-
MAX_PWM_CNT + 100)))
1990 if (((Motor[SyncMNos[0]].Speed <= 0) && (Motor[SyncMNos[0]].TargetSpeed <= 0)) ||
1991 ((Motor[SyncMNos[0]].Speed >= 0) && (Motor[SyncMNos[0]].TargetSpeed >= 0)))
1993 MaxSyncSpeed = Motor[SyncMNos[0]].
Speed;
1999 if ((Motor[SyncMNos[1]].Power > (
MAX_PWM_CNT - 100)) || (Motor[SyncMNos[1]].Power < (-
MAX_PWM_CNT + 100)))
2005 if (
TRUE ==
CheckLessThanSpecial((
SLONG)((Motor[SyncMNos[1]].Speed * 100)/(Motor[SyncMNos[1]].TurnRatio * Motor[SyncMNos[1]].Dir)), (
SLONG)(MaxSyncSpeed), Motor[SyncMNos[0]].Dir))
2007 if ((0 == Motor[SyncMNos[1]].TurnRatio) || (0 == Motor[SyncMNos[1]].Speed))
2014 if (((Motor[SyncMNos[1]].Speed <= 0) && (Motor[SyncMNos[1]].TargetSpeed <= 0)) ||
2015 ((Motor[SyncMNos[1]].Speed >= 0) && (Motor[SyncMNos[1]].TargetSpeed >= 0)))
2017 MaxSyncSpeed = ((Motor[SyncMNos[1]].
Speed * 100)/Motor[SyncMNos[1]].TurnRatio) * Motor[SyncMNos[1]].
Dir;
2024 if (
FALSE == Status)
2029 IncSpeed(Motor[SyncMNos[0]].Dir, &MaxSyncSpeed);
2035 if ((0 == Motor[SyncMNos[1]].TurnRatio) || (0 == MaxSyncSpeed))
2041 Motor[SyncMNos[1]].
TargetSpeed = ((MaxSyncSpeed * Motor[SyncMNos[1]].
TurnRatio)/100) * Motor[SyncMNos[1]].
Dir;
2044 if(0 != Motor[SyncMNos[1]].TurnRatio)
2046 if (
TRUE ==
CheckLessThanSpecial((((Motor[SyncMNos[1]].TachoCnt * 100)/Motor[SyncMNos[1]].TurnRatio) * Motor[SyncMNos[1]].Dir), Motor[SyncMNos[0]].
TachoCnt, Motor[SyncMNos[0]].
Dir))
2048 DecSpeed(Motor[SyncMNos[0]].Dir, &(Motor[SyncMNos[0]].TargetSpeed));
2052 if(0 != Motor[SyncMNos[1]].TurnRatio)
2054 if (
TRUE ==
CheckLessThanSpecial(Motor[SyncMNos[0]].TachoCnt, ((Motor[SyncMNos[1]].TachoCnt * 100)/(Motor[SyncMNos[1]].TurnRatio) * Motor[SyncMNos[1]].Dir), Motor[SyncMNos[0]].Dir))
2056 DecSpeed(Motor[SyncMNos[1]].Dir * Motor[SyncMNos[0]].Dir, &(Motor[SyncMNos[1]].TargetSpeed));
2071 SLONG Count0, Count1;
2073 if (StepPowerSteps[No] != &(Motor[No].TachoCnt))
2088 RampDownToBrake(SyncMNos[0], Count0, Motor[SyncMNos[0]].TachoCntConst, Motor[SyncMNos[0]].Dir);
2090 if (StepPowerSteps[SyncMNos[0]] == TimerSteps[SyncMNos[0]])
2094 RampDownToBrake(SyncMNos[1], ((Count1 * Motor[SyncMNos[1]].TurnRatio)/100),(( Motor[SyncMNos[1]].TachoCntConst * Motor[SyncMNos[1]].TurnRatio)/100), (Motor[SyncMNos[0]].Dir * Motor[SyncMNos[1]].Dir));
2098 RampDownToBrake(SyncMNos[1], Count1, Motor[SyncMNos[1]].TachoCntConst, (Motor[SyncMNos[0]].Dir * Motor[SyncMNos[1]].Dir));
2114 if (PrgStopTimer[No])
2144 return (HRTIMER_RESTART);
2150 if (StepPowerSteps[SyncMNos[0]] == TimerSteps[SyncMNos[0]])
2152 *pCount0 = *TimerSteps[SyncMNos[0]];
2153 *pCount1 = *TimerSteps[SyncMNos[1]];
2157 *pCount0 = *TachoSteps[SyncMNos[0]];
2158 *pCount1 = *TachoSteps[SyncMNos[1]];
2165 SLONG Count0, Count1;
2171 if (StepPowerSteps[SyncMNos[0]] == TimerSteps[SyncMNos[0]])
2173 Speed = (Motor[SyncMNos[0]].
Speed);
2177 Speed = (Motor[SyncMNos[0]].
Speed/2);
2181 (0 == Motor[SyncMNos[0]].TachoCntConst))
2226 static ssize_t Device1Write(
struct file *File,
const char *
Buffer,
size_t Count,loff_t *Data)
2232 copy_from_user(Buf,Buffer,Count);
2234 switch((
UBYTE)(Buf[0]))
2237 case opPROGRAM_STOP:
2241 for (Tmp = 0; Tmp <
OUTPUTS; Tmp++)
2245 ReadyStatus &= ~(0x01 << Tmp);
2246 TestStatus &= ~(0x01 << Tmp);
2248 Motor[Tmp].
Power = 0;
2249 Motor[Tmp].
Speed = 0;
2270 case opPROGRAM_START:
2274 for (Tmp = 0; Tmp <
OUTPUTS; Tmp++)
2283 case opOUTPUT_SET_TYPE:
2287 for (Tmp = 0; Tmp <
OUTPUTS; Tmp++)
2289 if (Buf[Tmp + 1] != Motor[Tmp].Type)
2305 Motor[Tmp].
Type = Buf[Tmp + 1];
2319 case opOUTPUT_RESET:
2325 for (Tmp = 0;Tmp <
OUTPUTS;Tmp++)
2327 if (Buf[1] & (1 << Tmp))
2339 case opOUTPUT_CLR_COUNT:
2342 for (Tmp = 0;Tmp <
OUTPUTS;Tmp++)
2344 if (Buf[1] & (1 << Tmp))
2361 for (Tmp = 0;Tmp <
OUTPUTS;Tmp++)
2363 if (Buf[1] & (1 << Tmp))
2382 case opOUTPUT_POWER:
2390 for (Tmp = 0;Tmp <
OUTPUTS;Tmp++)
2392 if (Buf[1] & (1 << Tmp))
2407 case opOUTPUT_SPEED:
2415 for (Tmp = 0;Tmp <
OUTPUTS;Tmp++)
2417 if (Buf[1] & (1 << Tmp))
2420 Motor[Tmp].
TargetSpeed = (Buf[2]) * (Motor[Tmp].Pol);
2431 case opOUTPUT_START:
2434 for (Tmp = 0;Tmp <
OUTPUTS;Tmp++)
2436 if (Buf[1] & (1 << Tmp))
2449 case opOUTPUT_POLARITY:
2455 for (Tmp = 0;Tmp <
OUTPUTS;Tmp++)
2457 if (Buf[1] & (1 << Tmp))
2460 if (0 == (
SBYTE)Buf[2])
2466 if (1 == Motor[Tmp].Pol)
2468 Motor[Tmp].
Pol = -1;
2478 if (Motor[Tmp].Pol != (
SBYTE)Buf[2])
2482 Motor[Tmp].
Pol = Buf[2];
2485 SetPower(Tmp, Motor[Tmp].TargetPower);
2492 case opOUTPUT_POSITION:
2497 case opOUTPUT_STEP_POWER:
2502 memcpy((
UBYTE*)(&(StepPower.
Cmd)), &Buf[0],
sizeof(StepPower));
2509 if (((StepPower.
Power < 0) && ((StepPower.
Step1 > 0) || (StepPower.
Step2 > 0) || (StepPower.
Step3 > 0))) ||
2510 ((StepPower.
Power > 0) && ((StepPower.
Step1 < 0) || (StepPower.
Step2 < 0) || (StepPower.
Step3 < 0))))
2512 StepPower.
Step1 *= -1;
2513 StepPower.
Step2 *= -1;
2514 StepPower.
Step3 *= -1;
2517 for (Tmp = 0;Tmp <
OUTPUTS;Tmp++)
2519 if (StepPower.
Nos & (1 << Tmp))
2523 StepPowerSteps[Tmp] = TachoSteps[Tmp];
2525 ReadyStatus |= (0x01 << Tmp);
2526 TestStatus |= (0x01 << Tmp);
2533 if (Motor[Tmp].TargetPower >= 0)
2539 Motor[Tmp].
Dir = -1;
2546 SLONG AdjustTachoValue = 0;
2558 case opOUTPUT_TIME_POWER:
2564 memcpy((
UBYTE*)(&(TimePower.
Cmd)), &Buf[0],
sizeof(TimePower));
2569 if (((TimePower.
Power < 0) && ((TimePower.
Time1 > 0) || (TimePower.
Time2 > 0) || (TimePower.
Time3 > 0))) ||
2570 ((TimePower.
Power > 0) && ((TimePower.
Time1 < 0) || (TimePower.
Time2 < 0) || (TimePower.
Time3 < 0))))
2572 TimePower.
Time1 *= -1;
2573 TimePower.
Time2 *= -1;
2574 TimePower.
Time3 *= -1;
2577 if ((TimePower.
Time1 > 0) || (TimePower.
Time2 > 0) || (TimePower.
Time3 > 0))
2586 for (Tmp = 0;Tmp <
OUTPUTS;Tmp++)
2588 if (TimePower.
Nos & (1 << Tmp))
2592 StepPowerSteps[Tmp] = TimerSteps[Tmp];
2594 *StepPowerSteps[Tmp] = 0;
2596 ReadyStatus |= (0x01 << Tmp);
2597 TestStatus |= (0x01 << Tmp);
2605 if (Motor[Tmp].TargetPower >= 0)
2611 Motor[Tmp].
Dir = -1;
2618 SLONG AdjustTachoValue = 0;
2630 case opOUTPUT_STEP_SPEED:
2635 memcpy((
UBYTE*)(&(StepSpeed.
Cmd)), &Buf[0],
sizeof(StepSpeed));
2642 if (((StepSpeed.
Speed < 0) && ((StepSpeed.
Step1 > 0) || (StepSpeed.
Step2 > 0) || (StepSpeed.
Step3 > 0))) ||
2643 ((StepSpeed.
Speed > 0) && ((StepSpeed.
Step1 < 0) || (StepSpeed.
Step2 < 0) || (StepSpeed.
Step3 < 0))))
2645 StepSpeed.
Step1 *= -1;
2646 StepSpeed.
Step2 *= -1;
2647 StepSpeed.
Step3 *= -1;
2650 for (Tmp = 0;Tmp <
OUTPUTS;Tmp++)
2652 if (StepSpeed.
Nos & (1 << Tmp))
2656 StepPowerSteps[Tmp] = TachoSteps[Tmp];
2658 ReadyStatus |= (0x01 << Tmp);
2659 TestStatus |= (0x01 << Tmp);
2667 if (Motor[Tmp].TargetPower >= 0)
2673 Motor[Tmp].
Dir = -1;
2680 SLONG AdjustTachoValue = 0;
2693 case opOUTPUT_TIME_SPEED:
2700 memcpy((
UBYTE*)(&(TimeSpeed.
Cmd)), &Buf[0],
sizeof(TimeSpeed));
2707 if (((TimeSpeed.
Speed < 0) && ((TimeSpeed.
Time1 > 0) || (TimeSpeed.
Time2 > 0) || (TimeSpeed.
Time3 > 0))) ||
2708 ((TimeSpeed.
Speed > 0) && ((TimeSpeed.
Time1 < 0) || (TimeSpeed.
Time2 < 0) || (TimeSpeed.
Time3 < 0))))
2710 TimeSpeed.
Time1 *= -1;
2711 TimeSpeed.
Time2 *= -1;
2712 TimeSpeed.
Time3 *= -1;
2715 if ((TimeSpeed.
Time1 > 0) || (TimeSpeed.
Time2 > 0) || (TimeSpeed.
Time3 > 0))
2724 for (Tmp = 0;Tmp <
OUTPUTS;Tmp++)
2726 if (TimeSpeed.
Nos & (1 << Tmp))
2730 StepPowerSteps[Tmp] = TimerSteps[Tmp];
2732 *StepPowerSteps[Tmp] = 0;
2734 ReadyStatus |= (0x01 << Tmp);
2735 TestStatus |= (0x01 << Tmp);
2743 if (Motor[Tmp].TargetPower >= 0)
2749 Motor[Tmp].
Dir = -1;
2756 SLONG AdjustTachoValue = 0;
2769 case opOUTPUT_STEP_SYNC:
2775 memcpy((
UBYTE*)(&(StepSync.
Cmd)), &Buf[0],
sizeof(StepSync));
2782 if (((StepSync.
Speed < 0) && (StepSync.
Step > 0)) ||
2783 ((StepSync.
Speed > 0) && (StepSync.
Step < 0)))
2785 StepSync.
Step *= -1;
2788 for (Tmp = 0;Tmp <
OUTPUTS;Tmp++)
2791 if (StepSync.
Nos & (1 << Tmp))
2795 ReadyStatus |= (0x01 << Tmp);
2796 TestStatus |= (0x01 << Tmp);
2797 StepPowerSteps[Tmp] = TachoSteps[Tmp];
2800 if (0 == StepSync.
Step)
2803 *StepPowerSteps[Tmp] = 0;
2806 if (0 == StepSync.
Turn)
2814 MaxSyncSpeed = StepSync.
Speed;
2817 if (0 <= StepSync.
Speed)
2841 if (0 < StepSync.
Turn)
2848 MotorIndex = 1 - No;
2851 if (0 == MotorIndex)
2853 if (StepSync.
Speed > 0)
2865 if ((StepSync.
Turn < 100) && (StepSync.
Turn > -100))
2869 if (StepSync.
Turn > 0)
2880 if ((StepSync.
Turn >= 100) || (StepSync.
Turn <= -100))
2884 if (StepSync.
Turn <= -100)
2896 SyncMNos[MotorIndex] = Tmp;
2898 if (0 > StepSync.
Turn)
2903 if (0 == MotorIndex)
2907 MaxSyncSpeed = StepSync.
Speed;
2927 case opOUTPUT_TIME_SYNC:
2934 memcpy((
UBYTE*)(&(TimeSync.
Cmd)), &Buf[0],
sizeof(TimeSync));
2941 if (((TimeSync.
Speed < 0) && (TimeSync.
Time > 0)) ||
2942 ((TimeSync.
Speed > 0) && (TimeSync.
Time < 0)))
2944 TimeSync.
Time *= -1;
2947 if (TimeSync.
Time > 0)
2956 for (Tmp = 0;Tmp <
OUTPUTS;Tmp++)
2958 if (TimeSync.
Nos & (1 << Tmp))
2962 ReadyStatus |= (0x01 << Tmp);
2963 TestStatus |= (0x01 << Tmp);
2965 StepPowerSteps[Tmp] = TimerSteps[Tmp];
2967 *TimerSteps[Tmp] = 0;
2971 if (0 == TimeSync.
Turn)
2979 MaxSyncSpeed = TimeSync.
Speed;
2982 if (0 <= TimeSync.
Speed)
3006 if (0 < TimeSync.
Turn)
3013 MotorIndex = 1 - No;
3016 if (0 == MotorIndex)
3018 if (TimeSync.
Speed > 0)
3030 if ((TimeSync.
Turn < 100) && (TimeSync.
Turn > -100))
3034 if (TimeSync.
Turn > 0)
3045 if ((TimeSync.
Turn >= 100) || (TimeSync.
Turn <= -100))
3049 if (TimeSync.
Turn <= -100)
3061 SyncMNos[MotorIndex] = Tmp;
3063 if (0 > TimeSync.
Turn)
3068 if (0 == MotorIndex)
3072 MaxSyncSpeed = TimeSync.
Speed;
3102 static ssize_t Device1Read(
struct file *File,
char *Buffer,
size_t Count,loff_t *Offset)
3106 Lng =
snprintf(&Buffer[0],Count,
"%01u ",ReadyStatus);
3107 Lng +=
snprintf(&Buffer[Lng],Count - Lng,
"%01u ",TestStatus);
3113 static const struct file_operations Device1Entries =
3115 .owner = THIS_MODULE,
3116 .read = Device1Read,
3117 .write = Device1Write
3121 static struct miscdevice Device1 =
3143 if (request_mem_region(Address,Size,
MODULE_NAME) >= 0)
3146 *Ptr = (
ULONG*)ioremap(Address,Size);
3151 printk(
"%s memory Remapped from 0x%08lX\n",
DEVICE1_NAME,(
unsigned long)*Ptr);
3156 printk(
"Memory remap ERROR");
3161 printk(
"Region request error");
3175 static int Device1Init(
void)
3190 Result = misc_register(&Device1);
3201 iowrite32(0x00000003, &PSC1[0x291]);
3202 iowrite32(0x00000003, &PSC1[0x48]);
3204 iowrite32((ioread32(&PSC1[0x294]) | 0x00000003), &PSC1[0x294]);
3205 iowrite32((ioread32(&PSC1[0x48]) | 0x00000003), &PSC1[0x48]);
3209 memset(&Motor[Tmp], 0,
sizeof(
MOTOR));
3249 static void Device1Exit(
void)
3251 hrtimer_cancel(&Device1Timer);
3252 misc_deregister(&Device1);
3271 static void __iomem *GpioBase;
3294 printk(
" GP%d_%-2d 0x%08X and 0x%08X or 0x%08X\n",(Pin >> 4),(Pin & 0x0F),(
u32)Reg,
MuxRegMap[Tmp].Mask,
MuxRegMap[Tmp].Mode);
3300 printk(
" OUTPUT FUNCTION 0x%08X and 0x%08X or 0x%08X\n",(
u32)Reg,
MuxRegMap[Tmp].Mask,
MuxRegMap[Tmp].Mode);
3306 printk(
" GP%d_%-2d Not found (Const no. %d, Tmp = %d)\n",(Pin >> 4),(Pin & 0x0F), Pin, Tmp);
3323 printk(
" Output port %d\n",Port + 1);
3327 if ((pOutputPortPin[
Hw][(Port * OUTPUT_PORT_PINS) + Pin].Pin) >= 0)
3329 pOutputPortPin[
Hw][(Port *
OUTPUT_PORT_PINS) + Pin].pGpio = (
struct gpio_controller *__iomem)(GpioBase + ((pOutputPortPin[
Hw][(Port *
OUTPUT_PORT_PINS) + Pin].Pin >> 5) * 0x28) + 0x10);
3330 pOutputPortPin[
Hw][(Port *
OUTPUT_PORT_PINS) + Pin].Mask = (1 << (pOutputPortPin[
Hw][(Port * OUTPUT_PORT_PINS) + Pin].
Pin & 0x1F));
3332 SetGpio(pOutputPortPin[
Hw][(Port * OUTPUT_PORT_PINS) + Pin].Pin);
3346 Status = request_irq(gpio_to_irq(PinNo), IntFuncPtr, 0,
"PWM_DEVICE",
NULL);
3349 printk(
"error %d requesting GPIO IRQ %d\n", Status, PinNo);
3351 set_irq_type(gpio_to_irq(PinNo), IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING);
3353 printk(
".. done\n");
3378 static irqreturn_t IntA (
int irq,
void * dev)
3394 if ((35 < Motor[0].Speed) || (-35 > Motor[0].
Speed))
3396 if (
FORWARD == Motor[0].Direction)
3415 if (
FORWARD == Motor[0].Direction)
3431 if (
BACKWARD == Motor[0].Direction)
3452 if (
BACKWARD == Motor[0].Direction)
3468 if (
FORWARD == Motor[0].Direction)
3488 static irqreturn_t IntB (
int irq,
void * dev)
3490 UBYTE volatile TmpPtr;
3491 ULONG volatile IntBState;
3492 ULONG volatile DirBState;
3504 if ((35 < Motor[1].Speed) || (-35 > Motor[1].
Speed))
3506 if (
FORWARD == Motor[1].Direction)
3526 if (
FORWARD == Motor[1].Direction)
3542 if (
BACKWARD == Motor[1].Direction)
3561 if (
BACKWARD == Motor[1].Direction)
3577 if (
FORWARD == Motor[1].Direction)
3597 static irqreturn_t IntC (
int irq,
void * dev)
3613 if ((35 < Motor[2].Speed) || (-35 > Motor[2].
Speed))
3615 if (
FORWARD == Motor[2].Direction)
3634 if (
FORWARD == Motor[2].Direction)
3650 if (
BACKWARD == Motor[2].Direction)
3669 if (
BACKWARD == Motor[2].Direction)
3685 if (
FORWARD == Motor[2].Direction)
3705 static irqreturn_t IntD (
int irq,
void * dev)
3721 if ((35 < Motor[3].Speed) || (-35 > Motor[3].
Speed))
3723 if (
FORWARD == Motor[3].Direction)
3742 if (
FORWARD == Motor[3].Direction)
3758 if (
BACKWARD == Motor[3].Direction)
3777 if (
BACKWARD == Motor[3].Direction)
3793 if (
FORWARD == Motor[3].Direction)
3990 if (Motor[No].DirChgPtr >= 1)
4007 if ((Ptr != TachoSamples[No].ArrayPtrOld) && (Motor[No].
DirChgPtr >= AVG_TACHO_COUNTS[No]))
4011 TimeOutSpeed0[No] = Tmp1;
4014 Diff = ((Tmp1-Tmp2) & 0x00FFFFFF);
4030 if (
BACKWARD == Motor[No].Direction)
4047 *pSpeed = (
SBYTE)Speed;
4064 static ssize_t Device2Write(
struct file *File,
const char *Buffer,
size_t Count,loff_t *Data)
4069 copy_from_user(Buf, Buffer, Count);
4071 ReadyStatus |= Buf[0];
4072 TestStatus |= Buf[0];
4088 static ssize_t Device2Read(
struct file *File,
char *Buffer,
size_t Count,loff_t *Offset)
4094 #define SHM_LENGTH (sizeof(MotorData))
4095 #define NPAGES ((SHM_LENGTH + PAGE_SIZE - 1) / PAGE_SIZE)
4096 static void *kmalloc_ptr;
4099 static int Device2Mmap(
struct file *filp,
struct vm_area_struct *vma)
4103 ret = remap_pfn_range(vma,vma->vm_start,virt_to_phys((
void*)((
unsigned long)pMotor)) >> PAGE_SHIFT,vma->vm_end-vma->vm_start,PAGE_SHARED);
4114 static const struct file_operations Device2Entries =
4116 .owner = THIS_MODULE,
4117 .read = Device2Read,
4118 .write = Device2Write,
4119 .mmap = Device2Mmap,
4123 static struct miscdevice Device2 =
4131 static int Device2Init(
void)
4137 Result = misc_register(&Device2);
4145 if ((kmalloc_ptr = kmalloc((
NPAGES + 2) * PAGE_SIZE, GFP_KERNEL)) !=
NULL)
4147 pTmp = (
MOTORDATA*)((((
unsigned long)kmalloc_ptr) + PAGE_SIZE - 1) & PAGE_MASK);
4148 for (i = 0; i <
NPAGES * PAGE_SIZE; i += PAGE_SIZE)
4150 SetPageReserved(virt_to_page(((
unsigned long)pTmp) + i));
4153 memset(pMotor,0,
sizeof(MotorData));
4168 static void Device2Exit(
void)
4176 for (i = 0; i <
NPAGES * PAGE_SIZE; i+= PAGE_SIZE)
4178 ClearPageReserved(virt_to_page(((
unsigned long)pTmp) + i));
4180 printk(
" %s memory page %d unmapped\n",
DEVICE1_NAME,i);
4185 misc_deregister(&Device2);
4196 static int ModuleInit(
void)
4213 if (request_mem_region(DA8XX_GPIO_BASE,0xD8,
MODULE_NAME) >= 0)
4215 GpioBase = (
void*)ioremap(DA8XX_GPIO_BASE,0xD8);
4216 if (GpioBase !=
NULL)
4272 hrtimer_init(&Device1Timer,CLOCK_MONOTONIC,HRTIMER_MODE_REL);
4273 Device1Timer.function = Device1TimerInterrupt1;
4274 hrtimer_start(&Device1Timer,Device1Time,HRTIMER_MODE_REL);
4281 static void ModuleExit(
void)
void dRegulateSpeed(UBYTE No)
dRegulateSpeed
#define SETMotorType(Port, NewType)
void FloatSyncedMotors(void)
#define COUNTS_PER_PULSE_LM
signed char SBYTE
Basic Type used to symbolise 8 bit signed values.
UWORD GetTachoInt(UBYTE Port)
MODULE_DESCRIPTION(MODULE_NAME)
UBYTE CheckLessThanSpecial(SLONG Param1, SLONG Param2, SLONG Inv)
UBYTE StepSpeedCheckTachoCntUp(UBYTE No)
StepSpeedCheckTachoCntUp.
#define EP2
Schematics revision D.
INPIN EP2_OutputPortPin[][OUTPUT_PORT_PINS]
void SetDirFwd(UBYTE Port)
void CheckSpeedPowerLimits(SBYTE *pCheckVal)
Port empty or not available.
#define FINAL
Final prototype.
#define NO_OF_OUTPUT_PORTS
void ClearPIDParameters(UBYTE No)
UBYTE StepPowerCheckTachoCntUp(UBYTE No)
StepPowerCheckTachoCntUp.
UBYTE StepPowerCheckTachoCntConst(UBYTE No, SLONG AdjustTachoValue)
StepPowerCheckTachoCntConst.
void SetDutyMC(ULONG Duty)
void SetRegulationPower(UBYTE Port, SLONG Power)
void StopAndBrakeMotor(UBYTE MotorNo)
void IncSpeed(SBYTE Dir, SBYTE *pSpeed)
module_param(HwId, charp, 0)
void GetSyncDurationCnt(SLONG *pCount0, SLONG *pCount1)
void TestAndFloatSyncedMotors(UBYTE MotorBitField, UBYTE SyncCmd)
void CheckforEndOfSync(void)
MODULE_AUTHOR("The LEGO Group")
INPIN FINAL_OutputPortPin[][OUTPUT_PORT_PINS]
void SetDutyMB(ULONG Duty)
unsigned int ULONG
Basic Type used to symbolise 32 bit unsigned values.
UWORD GetTachoDir(UBYTE Port)
void SetDutyMA(ULONG Duty)
void SetGpioRisingIrq(UBYTE PinNo, irqreturn_t(*IntFuncPtr)(int, void *))
#define FINALB
Schematics revision B and C.
void StepPowerStopMotor(UBYTE No, SLONG AdjustTachoValue)
StepPowerStopMotor.
void GetPeriphealBasePtr(ULONG Address, ULONG Size, ULONG **Ptr)
GetPeriphealBasePtr.
unsigned char UBYTE
Basic Type used to symbolise 8 bit unsigned values.
void SetPower(UBYTE Port, SLONG Power)
void SetCoast(UBYTE Port)
#define OutputRead(port, pin)
ULONG TachoArray[NO_OF_TACHO_SAMPLES]
unsigned short UWORD
Basic Type used to symbolise 16 bit unsigned values.
MODULE_SUPPORTED_DEVICE(DEVICE1_NAME)
#define OutputHigh(port, pin)
void GetCompareCounts(UBYTE No, SLONG *Counts, SLONG *CompareCounts)
#define OUTPUTS
Number of output ports in the system.
UBYTE RampDownToBrake(UBYTE No, SLONG CurrentCnt, SLONG TargetCnt, SLONG Dir)
signed short SWORD
Basic Type used to symbolise 16 bit signed values.
Device is a mini tacho motor.
UBYTE dCalculateSpeed(UBYTE No, SBYTE *pSpeed)
dCalculateSpeed
void SetDirRwd(UBYTE Port)
#define SETAvgTachoCount(Port, Speed)
INPIN FINALB_OutputPortPin[][OUTPUT_PORT_PINS]
void StepPowerCheckTachoCntDown(UBYTE No, SLONG AdjustTachoValue)
StepPowerCheckTachoCntDown.
#define CLEARTachoArray(No)
#define OutputLow(port, pin)
void StopAndFloatMotor(UBYTE MotorNo)
#define FREERunning24bittimer
#define PLATFORM_END
Newest supported hardware (newer versions will use this)
void SetBrake(UBYTE Port)
UBYTE StepSpeedCheckTachoCntConst(UBYTE No, SLONG AdjustTachoValue)
StepPowerCheckTachoCntConst.
void BrakeMotor(UBYTE No, SLONG TachoCnt)
void StepSpeedCheckTachoCntDown(UBYTE No, SLONG AdjustTachoValue)
StepSpeedCheckTachoCntDown.
#define OutputFloat(port, pin)
#define NO_OF_TACHO_SAMPLES
void CalcRampDownFactor(UBYTE No, ULONG CurrentPower, ULONG Counts)
void SetDutyMD(ULONG Duty)
void DecSpeed(SBYTE Dir, SBYTE *pSpeed)
signed int SLONG
Basic Type used to symbolise 32 bit signed values.
#define PLATFORM_START
Oldest supported hardware (older versions will use this)