summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeonghoon Park <jh1979.park@samsung.com>2017-12-18 10:12:02 +0900
committerJeonghoon Park <jh1979.park@samsung.com>2017-12-18 10:12:02 +0900
commitd8656e14b073084f170e25c469b37363fdb06878 (patch)
treeb969036f0a5fee106f8954e28453f10c0f8a4b06 /src
parent588e05f53ce6086714efc3be4b108db1b6899c9a (diff)
downloadgear-racing-car-d8656e14b073084f170e25c469b37363fdb06878.tar.gz
gear-racing-car-d8656e14b073084f170e25c469b37363fdb06878.tar.bz2
gear-racing-car-d8656e14b073084f170e25c469b37363fdb06878.zip
fix PCA9685 maximum channel number
Diffstat (limited to 'src')
-rw-r--r--src/resource/resource_PCA9685.c4
-rw-r--r--src/resource/resource_servo_motor.c6
2 files changed, 5 insertions, 5 deletions
diff --git a/src/resource/resource_PCA9685.c b/src/resource/resource_PCA9685.c
index a4c1e55..7481b1b 100644
--- a/src/resource/resource_PCA9685.c
+++ b/src/resource/resource_PCA9685.c
@@ -55,7 +55,7 @@ typedef enum {
static peripheral_i2c_h g_i2c_h = NULL;
static unsigned int ref_count = 0;
-static pca9685_ch_state_e ch_state[PCA9685_CH_MAX] = {PCA9685_CH_STATE_NONE, };
+static pca9685_ch_state_e ch_state[PCA9685_CH_MAX + 1] = {PCA9685_CH_STATE_NONE, };
int resource_pca9685_set_frequency(unsigned int freq_hz)
{
@@ -149,7 +149,7 @@ int resource_pca9685_init(unsigned int ch)
uint8_t mode1 = 0;
int ret = PERIPHERAL_ERROR_NONE;
- if (ch == 0 || ch >= PCA9685_CH_MAX) {
+ if (ch == 0 || ch > PCA9685_CH_MAX) {
_E("channel[%u] is out of range", ch);
return -1;
}
diff --git a/src/resource/resource_servo_motor.c b/src/resource/resource_servo_motor.c
index a1a2b69..512cc5b 100644
--- a/src/resource/resource_servo_motor.c
+++ b/src/resource/resource_servo_motor.c
@@ -21,7 +21,7 @@
#define SERVO_MOTOR_MAX PCA9685_CH_MAX
-static int servo_motor_index[SERVO_MOTOR_MAX] = {0, };
+static int servo_motor_index[SERVO_MOTOR_MAX + 1] = {0, };
static int resource_servo_motor_init(unsigned int ch)
{
@@ -50,7 +50,7 @@ void resource_close_servo_motor_all(void)
{
unsigned int i;
- for (i = 1; i < SERVO_MOTOR_MAX; i++)
+ for (i = 1; i <= SERVO_MOTOR_MAX; i++)
resource_close_servo_motor(i);
return;
@@ -63,7 +63,7 @@ int resource_set_servo_motor_value(unsigned int motor_id, int value)
if (motor_id == 0)
return -1;
- if (motor_id >= SERVO_MOTOR_MAX)
+ if (motor_id > SERVO_MOTOR_MAX)
return -1;
if (servo_motor_index[motor_id] == 0) {