added gps baudrage config setting

renamed gcc startup file to .S (breaks some lunix dudes apparently)
ppm sum handler waws hardcoded to TIM2 instead of using passed parameter. fixed. (thanks sbaron)
invalid data from pwm/ppm read are returned as midrc, not 1500. (robert_b)


git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@133 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
timecop 2012-03-27 12:55:44 +00:00
parent 791d67b4ee
commit da5ac020e1
9 changed files with 2413 additions and 2395 deletions

File diff suppressed because it is too large Load Diff

View File

@ -104,6 +104,7 @@ const clivalue_t valueTable[] = {
{ "tilt_roll_prop", VAR_INT8, &cfg.tilt_roll_prop, -100, 100 }, { "tilt_roll_prop", VAR_INT8, &cfg.tilt_roll_prop, -100, 100 },
{ "acc_lpf_factor", VAR_UINT8, &cfg.acc_lpf_factor, 0, 32 }, { "acc_lpf_factor", VAR_UINT8, &cfg.acc_lpf_factor, 0, 32 },
{ "gyro_lpf", VAR_UINT16, &cfg.gyro_lpf, 0, 256 }, { "gyro_lpf", VAR_UINT16, &cfg.gyro_lpf, 0, 256 },
{ "gps_baudrate", VAR_UINT16, &cfg.gps_baudrate, 1200, 57600 },
{ "p_pitch", VAR_UINT8, &cfg.P8[PITCH], 0, 200}, { "p_pitch", VAR_UINT8, &cfg.P8[PITCH], 0, 200},
{ "i_pitch", VAR_UINT8, &cfg.I8[PITCH], 0, 200}, { "i_pitch", VAR_UINT8, &cfg.I8[PITCH], 0, 200},
{ "d_pitch", VAR_UINT8, &cfg.D8[PITCH], 0, 200}, { "d_pitch", VAR_UINT8, &cfg.D8[PITCH], 0, 200},

View File

@ -2,14 +2,18 @@
#include "mw.h" #include "mw.h"
#include <string.h> #include <string.h>
#ifndef FLASH_PAGE_COUNT
#define FLASH_PAGE_COUNT 64
#endif
#define FLASH_PAGE_SIZE ((uint16_t)0x400) #define FLASH_PAGE_SIZE ((uint16_t)0x400)
#define FLASH_WRITE_ADDR (0x08000000 + (uint32_t)FLASH_PAGE_SIZE * 63) // use the last KB for storage #define FLASH_WRITE_ADDR (0x08000000 + (uint32_t)FLASH_PAGE_SIZE * (FLASH_PAGE_COUNT - 1)) // use the last KB for storage
config_t cfg; config_t cfg;
const char rcChannelLetters[] = "AERT1234"; const char rcChannelLetters[] = "AERT1234";
static uint32_t enabledSensors = 0; static uint32_t enabledSensors = 0;
static uint8_t checkNewConf = 8; static uint8_t checkNewConf = 9;
void parseRcChannels(const char *input) void parseRcChannels(const char *input)
{ {
@ -144,6 +148,9 @@ void checkFirstTime(bool reset)
cfg.tilt_pitch_prop = 10; cfg.tilt_pitch_prop = 10;
cfg.tilt_roll_prop = 10; cfg.tilt_roll_prop = 10;
// gps baud-rate
cfg.gps_baudrate = 9600;
writeParams(); writeParams();
} }

View File

@ -71,13 +71,13 @@ static void ppmIRQHandler(TIM_TypeDef *tim)
static uint16_t last = 0; static uint16_t last = 0;
static uint8_t chan = 0; static uint8_t chan = 0;
if (TIM_GetITStatus(TIM2, TIM_IT_CC1) == SET) { if (TIM_GetITStatus(tim, TIM_IT_CC1) == SET) {
last = now; last = now;
now = TIM_GetCapture1(TIM2); now = TIM_GetCapture1(tim);
rcActive = true; rcActive = true;
} }
TIM_ClearITPendingBit(TIM2, TIM_IT_CC1); TIM_ClearITPendingBit(tim, TIM_IT_CC1);
if (now > last) { if (now > last) {
diff = (now - last); diff = (now - last);

View File

@ -9,7 +9,7 @@ static void GPS_NewData(uint16_t c);
static bool GPS_newFrame(char c); static bool GPS_newFrame(char c);
static void GPS_distance(int32_t lat1, int32_t lon1, int32_t lat2, int32_t lon2, uint16_t * dist, int16_t * bearing); static void GPS_distance(int32_t lat1, int32_t lon1, int32_t lat2, int32_t lon2, uint16_t * dist, int16_t * bearing);
void gpsInit(void) void gpsInit(uint32_t baudrate)
{ {
uart2Init(9600, GPS_NewData); uart2Init(9600, GPS_NewData);
sensorsSet(SENSOR_GPS); sensorsSet(SENSOR_GPS);

View File

@ -87,7 +87,7 @@ int main(void)
// spektrum and GPS are mutually exclusive // spektrum and GPS are mutually exclusive
// Optional GPS - available only when using PPM, otherwise required pins won't be usable // Optional GPS - available only when using PPM, otherwise required pins won't be usable
if (feature(FEATURE_PPM) && feature(FEATURE_GPS)) if (feature(FEATURE_PPM) && feature(FEATURE_GPS))
gpsInit(); gpsInit(cfg.gps_baudrate);
} }
previousTime = micros(); previousTime = micros();

View File

@ -279,7 +279,7 @@ uint16_t pwmReadRawRC(uint8_t chan)
failsafeCnt = 0; failsafeCnt = 0;
data = pwmRead(cfg.rcmap[chan]); data = pwmRead(cfg.rcmap[chan]);
if (data < 750 || data > 2250) if (data < 750 || data > 2250)
data = 1500; data = cfg.midrc;
return data; return data;
} }

View File

@ -179,6 +179,9 @@ typedef struct config_t {
int8_t tilt_pitch_prop; // servo proportional (tied to angle) ; can be negative to invert movement int8_t tilt_pitch_prop; // servo proportional (tied to angle) ; can be negative to invert movement
int8_t tilt_roll_prop; // servo proportional (tied to angle) ; can be negative to invert movement int8_t tilt_roll_prop; // servo proportional (tied to angle) ; can be negative to invert movement
// gps baud-rate
uint16_t gps_baudrate;
} config_t; } config_t;
extern int16_t gyroZero[3]; extern int16_t gyroZero[3];
@ -292,4 +295,4 @@ bool spektrumFrameComplete(void);
void cliProcess(void); void cliProcess(void);
// gps // gps
void gpsInit(void); void gpsInit(uint32_t baudrate);