Last version from HackWAW. See ya next year!
parent
5e69055781
commit
d1048322ce
4
test.py
4
test.py
|
@ -1,8 +1,12 @@
|
||||||
import serial
|
import serial
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
s = serial.Serial("/dev/ttyACM0", 115200, timeout=10)
|
s = serial.Serial("/dev/ttyACM0", 115200, timeout=10)
|
||||||
|
|
||||||
|
def fire():
|
||||||
|
s.write("c\xFF")
|
||||||
|
fire()
|
||||||
#s.write("r")
|
#s.write("r")
|
||||||
#print s.read()
|
#print s.read()
|
||||||
s.write("a" + chr(int(sys.argv[1])))
|
s.write("a" + chr(int(sys.argv[1])))
|
||||||
|
|
41
uart_echo.c
41
uart_echo.c
|
@ -97,6 +97,8 @@ typedef unsigned char u8;
|
||||||
typedef char s8;
|
typedef char s8;
|
||||||
typedef unsigned int u32;
|
typedef unsigned int u32;
|
||||||
|
|
||||||
|
volatile u32 g_FiredTime = 0;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct {
|
struct {
|
||||||
u32 Servo1 : 1,
|
u32 Servo1 : 1,
|
||||||
|
@ -119,7 +121,8 @@ struct {
|
||||||
void CommitState(void)
|
void CommitState(void)
|
||||||
{
|
{
|
||||||
// F4 = fire
|
// 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)
|
void ClearNext(void)
|
||||||
|
@ -131,10 +134,18 @@ void ClearNext(void)
|
||||||
g_OutputControl.NextReceive.Digital.C = 0;
|
g_OutputControl.NextReceive.Digital.C = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 Timer0Counter = 0;
|
volatile u32 Timer0Counter = 0;
|
||||||
|
volatile u32 MiliCounter = 0;
|
||||||
|
u32 MiliSubCounter = 0;
|
||||||
void Timer0Handler(void)
|
void Timer0Handler(void)
|
||||||
{
|
{
|
||||||
ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
|
ROM_TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
|
||||||
|
MiliSubCounter++;
|
||||||
|
if (MiliSubCounter >= 100)
|
||||||
|
{
|
||||||
|
MiliSubCounter = 0;
|
||||||
|
MiliCounter++;
|
||||||
|
}
|
||||||
Timer0Counter++;
|
Timer0Counter++;
|
||||||
|
|
||||||
if (Timer0Counter >= 2000)
|
if (Timer0Counter >= 2000)
|
||||||
|
@ -146,11 +157,20 @@ void Timer0Handler(void)
|
||||||
GPIOPinWrite(GPIO_PORTA_BASE, GPIO_PIN_3, GPIO_PIN_3);
|
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);
|
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);
|
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
|
void
|
||||||
|
@ -180,17 +200,24 @@ UARTIntHandler(void)
|
||||||
u8 Sent = 0;
|
u8 Sent = 0;
|
||||||
if (g_OutputControl.NextReceive.Digital.A)
|
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;
|
Sent = 1;
|
||||||
}
|
}
|
||||||
else if (g_OutputControl.NextReceive.Servo1)
|
else if (g_OutputControl.NextReceive.Servo1)
|
||||||
{
|
{
|
||||||
g_OutputControl.Servo1 = (Data * 100) / 256;
|
UARTSend("s1 ", 3);
|
||||||
|
g_OutputControl.Servo1 = (Data * 200) / 256;
|
||||||
Sent = 1;
|
Sent = 1;
|
||||||
}
|
}
|
||||||
else if (g_OutputControl.NextReceive.Servo2)
|
else if (g_OutputControl.NextReceive.Servo2)
|
||||||
{
|
{
|
||||||
g_OutputControl.Servo2 = (Data * 100) / 256;
|
UARTSend("s2, ", 4);
|
||||||
|
g_OutputControl.Servo2 = (Data * 200) / 256;
|
||||||
//UARTSend("b", 1);
|
//UARTSend("b", 1);
|
||||||
Sent = 1;
|
Sent = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue