#ifndef __RESOURCE_PCA9685_H__
#define __RESOURCE_PCA9685_H__
-#define PCA9685_CH_MAX 16
+#define PCA9685_CH_MAX 15
int resource_pca9685_init(unsigned int ch);
int resource_pca9685_fini(unsigned int ch);
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)
{
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;
}
#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)
{
{
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;
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) {