Last version from HackWAW. See ya next year!

master
q3k 2012-11-11 23:03:15 +01:00
parent 5e69055781
commit d1048322ce
2 changed files with 38 additions and 7 deletions

View File

@ -1,8 +1,12 @@
import serial
import sys
import time
s = serial.Serial("/dev/ttyACM0", 115200, timeout=10)
def fire():
s.write("c\xFF")
fire()
#s.write("r")
#print s.read()
s.write("a" + chr(int(sys.argv[1])))

View File

@ -97,6 +97,8 @@ typedef unsigned char u8;
typedef char s8;
typedef unsigned int u32;
volatile u32 g_FiredTime = 0;
struct {
struct {
u32 Servo1 : 1,
@ -119,7 +121,8 @@ struct {
void CommitState(void)
{
// F4 = fire
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, g_OutputControl.Digital.A ? GPIO_PIN_4 : 0);
//GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_4, g_OutputControl.Digital.A ? GPIO_PIN_4 : 0);
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, g_OutputControl.Digital.A ? GPIO_PIN_2 : 0);
}
void ClearNext(void)
@ -131,10 +134,18 @@ void ClearNext(void)
g_OutputControl.NextReceive.Digital.C = 0;
}
u32 Timer0Counter = 0;
volatile u32 Timer0Counter = 0;
volatile u32 MiliCounter = 0;
u32 MiliSubCounter = 0;
void Timer0Handler(void)
{
ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
MiliSubCounter++;
if (MiliSubCounter >= 100)
{
MiliSubCounter = 0;
MiliCounter++;
}
Timer0Counter++;
if (Timer0Counter >= 2000)
@ -146,11 +157,20 @@ void Timer0Handler(void)
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_PIN_3);
}
if (Timer0Counter == 100 + g_OutputControl.Servo1)
if (Timer0Counter == 50 + g_OutputControl.Servo1)
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_2, 0);
if (Timer0Counter == 100 + g_OutputControl.Servo2)
if (Timer0Counter == 50 + g_OutputControl.Servo2)
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, 0);
if (g_OutputControl.Digital.A)
{
if (MiliCounter > (g_FiredTime + 200))
{
g_OutputControl.Digital.A = 0;
CommitState();
}
}
}
void
@ -180,17 +200,24 @@ UARTIntHandler(void)
u8 Sent = 0;
if (g_OutputControl.NextReceive.Digital.A)
{
g_OutputControl.Digital.A = Data > 0 ? 1 : 0;
if (Data > 0)
{
UARTSend("start ", 6);
g_FiredTime = MiliCounter;
g_OutputControl.Digital.A = 1;
}
Sent = 1;
}
else if (g_OutputControl.NextReceive.Servo1)
{
g_OutputControl.Servo1 = (Data * 100) / 256;
UARTSend("s1 ", 3);
g_OutputControl.Servo1 = (Data * 200) / 256;
Sent = 1;
}
else if (g_OutputControl.NextReceive.Servo2)
{
g_OutputControl.Servo2 = (Data * 100) / 256;
UARTSend("s2, ", 4);
g_OutputControl.Servo2 = (Data * 200) / 256;
//UARTSend("b", 1);
Sent = 1;
}