Compare commits

...

3 commits

Author SHA1 Message Date
2a728b61fb leds: include the missing utils.h to pull in ARRAYLEN.
Signed-off-by: Michael Hope <mlhx@google.com>
2015-05-29 05:36:31 +02:00
903863668a various: use enums to make the code easier to read.
Signed-off-by: Michael Hope <mlhx@google.com>
2015-05-29 05:36:08 +02:00
79e5c951ce various: use ARRAYLEN() in more places.
Signed-off-by: Michael Hope <mlhx@google.com>
2015-05-29 05:35:54 +02:00
5 changed files with 28 additions and 14 deletions

View file

@ -21,6 +21,8 @@
#include "platform.h"
#include "common/utils.h"
#include "system.h"
#include "gpio.h"
@ -56,7 +58,7 @@ void ledInit(void)
#endif
};
uint8_t gpio_count = sizeof(gpio_setup) / sizeof(gpio_setup[0]);
uint8_t gpio_count = ARRAYLEN(gpio_setup);
#ifdef LED0
RCC_APB2PeriphClockCmd(LED0_PERIPHERAL, ENABLE);

View file

@ -21,6 +21,8 @@
#include "platform.h"
#include "common/utils.h"
#include "gpio.h"
#include "light_led.h"
@ -47,7 +49,7 @@ void ledInit(void)
#endif
};
uint8_t gpio_count = sizeof(gpio_setup) / sizeof(gpio_setup[0]);
uint8_t gpio_count = ARRAYLEN(gpio_setup);
#ifdef LED0
RCC_AHBPeriphClockCmd(LED0_PERIPHERAL, ENABLE);

View file

@ -756,26 +756,26 @@ static void pidRewrite(pidProfile_t *pidProfile, controlRateConfig_t *controlRat
}
}
void pidSetController(int type)
void pidSetController(pidControllerType_e type)
{
switch (type) {
case 0:
case PID_CONTROLLER_MULTI_WII:
default:
pid_controller = pidMultiWii;
break;
case 1:
case PID_CONTROLLER_REWRITE:
pid_controller = pidRewrite;
break;
case 2:
case PID_CONTROLLER_LUX_FLOAT:
pid_controller = pidLuxFloat;
break;
case 3:
case PID_CONTROLLER_MULTI_WII_23:
pid_controller = pidMultiWii23;
break;
case 4:
case PID_CONTROLLER_MULTI_WII_HYBRID:
pid_controller = pidMultiWiiHybrid;
break;
case 5:
case PID_CONTROLLER_HARAKIRI:
pid_controller = pidHarakiri;
}
}

View file

@ -38,6 +38,15 @@ typedef enum {
PID_ITEM_COUNT
} pidIndex_e;
typedef enum {
PID_CONTROLLER_MULTI_WII,
PID_CONTROLLER_REWRITE,
PID_CONTROLLER_LUX_FLOAT,
PID_CONTROLLER_MULTI_WII_23,
PID_CONTROLLER_MULTI_WII_HYBRID,
PID_CONTROLLER_HARAKIRI,
} pidControllerType_e;
#define IS_PID_CONTROLLER_FP_BASED(pidController) (pidController == 2)
typedef struct pidProfile_s {
@ -63,7 +72,7 @@ typedef struct pidProfile_s {
extern int16_t axisPID[XYZ_AXIS_COUNT];
extern int32_t axisPID_P[3], axisPID_I[3], axisPID_D[3];
void pidSetController(int type);
void pidSetController(pidControllerType_e type);
void pidResetErrorAngle(void);
void pidResetErrorGyro(void);

View file

@ -28,6 +28,7 @@
#include "common/maths.h"
#include "common/axis.h"
#include "common/utils.h"
#include "drivers/system.h"
#include "drivers/serial.h"
@ -169,14 +170,14 @@ static const ubloxSbas_t ubloxSbas[] = {
};
enum {
typedef enum {
GPS_UNKNOWN,
GPS_INITIALIZING,
GPS_CHANGE_BAUD,
GPS_CONFIGURE,
GPS_RECEIVING_DATA,
GPS_LOST_COMMUNICATION,
};
} gpsState_e;
gpsData_t gpsData;
@ -185,7 +186,7 @@ static void shiftPacketLog(void)
{
uint32_t i;
for (i = sizeof(gpsPacketLog) - 1; i > 0 ; i--) {
for (i = ARRAYLEN(gpsPacketLog) - 1; i > 0 ; i--) {
gpsPacketLog[i] = gpsPacketLog[i-1];
}
}
@ -194,7 +195,7 @@ static void gpsNewData(uint16_t c);
static bool gpsNewFrameNMEA(char c);
static bool gpsNewFrameUBLOX(uint8_t data);
static void gpsSetState(uint8_t state)
static void gpsSetState(gpsState_e state)
{
gpsData.state = state;
gpsData.state_position = 0;