Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
deltaflight
deltaflight
Commits
a7532c60
Commit
a7532c60
authored
Jun 25, 2015
by
Dominic Clifton
Browse files
Merge pull request #942 from nzmichaelh/tidy
various: improve readability by using enums and ARRAYLEN()
parents
87b1d21d
0aceee00
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/drivers/light_led_stm32f10x.c
View file @
a7532c60
...
...
@@ -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
);
...
...
src/main/drivers/light_led_stm32f30x.c
View file @
a7532c60
...
...
@@ -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
);
...
...
src/main/flight/pid.c
View file @
a7532c60
...
...
@@ -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_2
3
:
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
;
}
}
...
...
src/main/flight/pid.h
View file @
a7532c60
...
...
@@ -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
);
...
...
src/main/io/gps.c
View file @
a7532c60
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment