Paparazzi UAS  v6.0_unstable-20-gfdbd467-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
pca9685_i2c.c File Reference
+ Include dependency graph for pca9685_i2c.c:

Go to the source code of this file.

Macros

#define BUF2INT(_buf, _idx)   ((int16_t)((_buf[_idx+1]<<8) | _buf[_idx]))
 
#define INT2BUF(_int, _buf, _idx)   { _buf[_idx] = _int; _buf[_idx+1] = (_int>>8); }
 
#define PCA9685_I2C_DEV   i2c2
 
#define PCA9865_SRV_RESOLUTION   1.
 
#define PCA9865_SRV_DEFAULT_VAL_US   1000.
 
#define PCA9865_SRV_NUMBER   16
 
#define PCA9685_I2C_SLAVE_ADDR   0xE0
 
#define PCA9685_I2C_ALLCALL_ADDR   0xE0
 
#define PCA9685_I2C_RESET_ADDR   0x06
 
#define PCA9685_I2C_GEN_CALL_ADDR   0x00
 
#define PCA9685_MODE1_REG_ADDR   0x00
 
#define PCA9685_MODE2_REG_ADDR   0x01
 
#define PCA9685_ALLCALL_ADDR   0x05
 
#define PCA9685_LED0_ON_L_REG_ADDR   0X06
 
#define PCA9685_LED0_ON_H_REG_ADDR   0X07
 
#define PCA9685_LED0_OFF_L_REG_ADDR   0X08
 
#define PCA9685_LED0_OFF_H_REG_ADDR   0X09
 
#define PCA9685_LED1_ON_L_REG_ADDR   0X0A
 
#define PCA9685_LED1_ON_H_REG_ADDR   0X0B
 
#define PCA9685_LED1_OFF_L_REG_ADDR   0X0C
 
#define PCA9685_LED1_OFF_H_REG_ADDR   0X0D
 
#define PCA9685_LED2_ON_L_REG_ADDR   0X0E
 
#define PCA9685_LED2_ON_H_REG_ADDR   0X0F
 
#define PCA9685_LED2_OFF_L_REG_ADDR   0X10
 
#define PCA9685_LED2_OFF_H_REG_ADDR   0X11
 
#define PCA9685_LED3_ON_L_REG_ADDR   0X12
 
#define PCA9685_LED3_ON_H_REG_ADDR   0X13
 
#define PCA9685_LED3_OFF_L_REG_ADDR   0X14
 
#define PCA9685_LED3_OFF_H_REG_ADDR   0X15
 
#define PCA9685_LED4_ON_L_REG_ADDR   0X16
 
#define PCA9685_LED4_ON_H_REG_ADDR   0X17
 
#define PCA9685_LED4_OFF_L_REG_ADDR   0X18
 
#define PCA9685_LED4_OFF_H_REG_ADDR   0X19
 
#define PCA9685_LED5_ON_L_REG_ADDR   0X1A
 
#define PCA9685_LED5_ON_H_REG_ADDR   0X1B
 
#define PCA9685_LED5_OFF_L_REG_ADDR   0X1C
 
#define PCA9685_LED5_OFF_H_REG_ADDR   0X1D
 
#define PCA9685_LED6_ON_L_REG_ADDR   0X1E
 
#define PCA9685_LED6_ON_H_REG_ADDR   0X1F
 
#define PCA9685_LED6_OFF_L_REG_ADDR   0X20
 
#define PCA9685_LED6_OFF_H_REG_ADDR   0X21
 
#define PCA9685_LED7_ON_L_REG_ADDR   0X22
 
#define PCA9685_LED7_ON_H_REG_ADDR   0X23
 
#define PCA9685_LED7_OFF_L_REG_ADDR   0X24
 
#define PCA9685_LED7_OFF_H_REG_ADDR   0X25
 
#define PCA9685_LED8_ON_L_REG_ADDR   0X26
 
#define PCA9685_LED8_ON_H_REG_ADDR   0X27
 
#define PCA9685_LED8_OFF_L_REG_ADDR   0X28
 
#define PCA9685_LED8_OFF_H_REG_ADDR   0X29
 
#define PCA9685_LED9_ON_L_REG_ADDR   0X2A
 
#define PCA9685_LED9_ON_H_REG_ADDR   0X2B
 
#define PCA9685_LED9_OFF_L_REG_ADDR   0X2C
 
#define PCA9685_LED9_OFF_H_REG_ADDR   0X2D
 
#define PCA9685_LED10_ON_L_REG_ADDR   0X2E
 
#define PCA9685_LED10_ON_H_REG_ADDR   0X2F
 
#define PCA9685_LED10_OFF_L_REG_ADDR   0X30
 
#define PCA9685_LED10_OFF_H_REG_ADDR   0X31
 
#define PCA9685_LED11_ON_L_REG_ADDR   0X32
 
#define PCA9685_LED11_ON_H_REG_ADDR   0X33
 
#define PCA9685_LED11_OFF_L_REG_ADDR   0X34
 
#define PCA9685_LED11_OFF_H_REG_ADDR   0X35
 
#define PCA9685_LED12_ON_L_REG_ADDR   0X36
 
#define PCA9685_LED12_ON_H_REG_ADDR   0X37
 
#define PCA9685_LED12_OFF_L_REG_ADDR   0X38
 
#define PCA9685_LED12_OFF_H_REG_ADDR   0X39
 
#define PCA9685_LED13_ON_L_REG_ADDR   0X3A
 
#define PCA9685_LED13_ON_H_REG_ADDR   0X3B
 
#define PCA9685_LED13_OFF_L_REG_ADDR   0X3C
 
#define PCA9685_LED13_OFF_H_REG_ADDR   0X3D
 
#define PCA9685_LED14_ON_L_REG_ADDR   0X3E
 
#define PCA9685_LED14_ON_H_REG_ADDR   0X3F
 
#define PCA9685_LED14_OFF_L_REG_ADDR   0X40
 
#define PCA9685_LED14_OFF_H_REG_ADDR   0X41
 
#define PCA9685_LED15_ON_L_REG_ADDR   0X42
 
#define PCA9685_LED15_ON_H_REG_ADDR   0X43
 
#define PCA9685_LED15_OFF_L_REG_ADDR   0X44
 
#define PCA9685_LED15_OFF_H_REG_ADDR   0X45
 
#define PCA9685_ALL_LED_ON_L_REG_ADDR   0XFA
 
#define PCA9685_ALL_LED_ON_H_REG_ADDR   0XFB
 
#define PCA9685_ALL_LED_OFF_L_REG_ADDR   0XFC
 
#define PCA9685_ALL_LED_OFF_H_REG_ADDR   0XFD
 
#define PCA9685_PRESCALER_REG_ADDR   0XFE
 
#define PCA9865_RESTART_BIT   7
 
#define PCA9865_AUTO_INCREMENT_BIT   5
 
#define PCA9865_SLEEP_BIT   4
 
#define PCA9865_ALLCALL_BIT   0
 
#define PCA9865_OUTDRV_BIT   2
 

Enumerations

enum  {
  PCA9685_I2C_STATUS_UNINIT, PCA9685_I2C_STATUS_INITIALIZED, PCA9865_I2C_STATUS_WRITE_LED_REG_BUSY, PCA9865_I2C_STATUS_WRITE_LED_REG_READY,
  PCA9865_I2C_STATUS_READ_LED_REG_BUSY, PCA9865_I2C_STATUS_CHANGE_LED_REG_FINISHED
}
 

Functions

bool pca9865_set_servo (uint8_t srv_nb, uint16_t srv_val)
 
void pca9685_i2c_init (void)
 
void pca9685_i2c_periodic (void)
 
void pca9685_i2c_event (void)
 

Variables

struct i2c_transaction pca9685_i2c_trans
 
uint8_t pca9685_i2c_status = 0
 
uint8_t srv_cnt = 0
 
uint16_t pca9865_write_servo_vals [PCA9865_SRV_NUMBER]
 
uint8_t pca9865_reg_nb [16]
 

Macro Definition Documentation

#define BUF2INT (   _buf,
  _idx 
)    ((int16_t)((_buf[_idx+1]<<8) | _buf[_idx]))

Definition at line 58 of file pca9685_i2c.c.

Referenced by pca9685_i2c_event().

#define INT2BUF (   _int,
  _buf,
  _idx 
)    { _buf[_idx] = _int; _buf[_idx+1] = (_int>>8); }

Definition at line 59 of file pca9685_i2c.c.

#define PCA9685_ALL_LED_OFF_H_REG_ADDR   0XFD

Definition at line 183 of file pca9685_i2c.c.

#define PCA9685_ALL_LED_OFF_L_REG_ADDR   0XFC

Definition at line 182 of file pca9685_i2c.c.

#define PCA9685_ALL_LED_ON_H_REG_ADDR   0XFB

Definition at line 181 of file pca9685_i2c.c.

#define PCA9685_ALL_LED_ON_L_REG_ADDR   0XFA

Definition at line 180 of file pca9685_i2c.c.

Referenced by pca9685_i2c_init().

#define PCA9685_ALLCALL_ADDR   0x05

Definition at line 97 of file pca9685_i2c.c.

#define PCA9685_I2C_ALLCALL_ADDR   0xE0

Definition at line 85 of file pca9685_i2c.c.

Referenced by pca9685_i2c_init().

#define PCA9685_I2C_DEV   i2c2

Definition at line 62 of file pca9685_i2c.c.

Referenced by pca9685_i2c_event(), pca9685_i2c_init(), and pca9685_i2c_periodic().

#define PCA9685_I2C_GEN_CALL_ADDR   0x00

Definition at line 91 of file pca9685_i2c.c.

Referenced by pca9685_i2c_init().

#define PCA9685_I2C_RESET_ADDR   0x06

Definition at line 88 of file pca9685_i2c.c.

Referenced by pca9685_i2c_init().

#define PCA9685_I2C_SLAVE_ADDR   0xE0

Definition at line 80 of file pca9685_i2c.c.

Referenced by pca9685_i2c_event(), pca9685_i2c_init(), and pca9685_i2c_periodic().

#define PCA9685_LED0_OFF_H_REG_ADDR   0X09

Definition at line 102 of file pca9685_i2c.c.

#define PCA9685_LED0_OFF_L_REG_ADDR   0X08

Definition at line 101 of file pca9685_i2c.c.

#define PCA9685_LED0_ON_H_REG_ADDR   0X07

Definition at line 100 of file pca9685_i2c.c.

#define PCA9685_LED0_ON_L_REG_ADDR   0X06

Definition at line 99 of file pca9685_i2c.c.

#define PCA9685_LED10_OFF_H_REG_ADDR   0X31

Definition at line 153 of file pca9685_i2c.c.

#define PCA9685_LED10_OFF_L_REG_ADDR   0X30

Definition at line 152 of file pca9685_i2c.c.

#define PCA9685_LED10_ON_H_REG_ADDR   0X2F

Definition at line 151 of file pca9685_i2c.c.

#define PCA9685_LED10_ON_L_REG_ADDR   0X2E

Definition at line 150 of file pca9685_i2c.c.

#define PCA9685_LED11_OFF_H_REG_ADDR   0X35

Definition at line 158 of file pca9685_i2c.c.

#define PCA9685_LED11_OFF_L_REG_ADDR   0X34

Definition at line 157 of file pca9685_i2c.c.

#define PCA9685_LED11_ON_H_REG_ADDR   0X33

Definition at line 156 of file pca9685_i2c.c.

#define PCA9685_LED11_ON_L_REG_ADDR   0X32

Definition at line 155 of file pca9685_i2c.c.

#define PCA9685_LED12_OFF_H_REG_ADDR   0X39

Definition at line 163 of file pca9685_i2c.c.

#define PCA9685_LED12_OFF_L_REG_ADDR   0X38

Definition at line 162 of file pca9685_i2c.c.

#define PCA9685_LED12_ON_H_REG_ADDR   0X37

Definition at line 161 of file pca9685_i2c.c.

#define PCA9685_LED12_ON_L_REG_ADDR   0X36

Definition at line 160 of file pca9685_i2c.c.

#define PCA9685_LED13_OFF_H_REG_ADDR   0X3D

Definition at line 168 of file pca9685_i2c.c.

#define PCA9685_LED13_OFF_L_REG_ADDR   0X3C

Definition at line 167 of file pca9685_i2c.c.

#define PCA9685_LED13_ON_H_REG_ADDR   0X3B

Definition at line 166 of file pca9685_i2c.c.

#define PCA9685_LED13_ON_L_REG_ADDR   0X3A

Definition at line 165 of file pca9685_i2c.c.

#define PCA9685_LED14_OFF_H_REG_ADDR   0X41

Definition at line 173 of file pca9685_i2c.c.

#define PCA9685_LED14_OFF_L_REG_ADDR   0X40

Definition at line 172 of file pca9685_i2c.c.

#define PCA9685_LED14_ON_H_REG_ADDR   0X3F

Definition at line 171 of file pca9685_i2c.c.

#define PCA9685_LED14_ON_L_REG_ADDR   0X3E

Definition at line 170 of file pca9685_i2c.c.

#define PCA9685_LED15_OFF_H_REG_ADDR   0X45

Definition at line 178 of file pca9685_i2c.c.

#define PCA9685_LED15_OFF_L_REG_ADDR   0X44

Definition at line 177 of file pca9685_i2c.c.

#define PCA9685_LED15_ON_H_REG_ADDR   0X43

Definition at line 176 of file pca9685_i2c.c.

#define PCA9685_LED15_ON_L_REG_ADDR   0X42

Definition at line 175 of file pca9685_i2c.c.

#define PCA9685_LED1_OFF_H_REG_ADDR   0X0D

Definition at line 107 of file pca9685_i2c.c.

#define PCA9685_LED1_OFF_L_REG_ADDR   0X0C

Definition at line 106 of file pca9685_i2c.c.

#define PCA9685_LED1_ON_H_REG_ADDR   0X0B

Definition at line 105 of file pca9685_i2c.c.

#define PCA9685_LED1_ON_L_REG_ADDR   0X0A

Definition at line 104 of file pca9685_i2c.c.

#define PCA9685_LED2_OFF_H_REG_ADDR   0X11

Definition at line 112 of file pca9685_i2c.c.

#define PCA9685_LED2_OFF_L_REG_ADDR   0X10

Definition at line 111 of file pca9685_i2c.c.

#define PCA9685_LED2_ON_H_REG_ADDR   0X0F

Definition at line 110 of file pca9685_i2c.c.

#define PCA9685_LED2_ON_L_REG_ADDR   0X0E

Definition at line 109 of file pca9685_i2c.c.

#define PCA9685_LED3_OFF_H_REG_ADDR   0X15

Definition at line 117 of file pca9685_i2c.c.

#define PCA9685_LED3_OFF_L_REG_ADDR   0X14

Definition at line 116 of file pca9685_i2c.c.

#define PCA9685_LED3_ON_H_REG_ADDR   0X13

Definition at line 115 of file pca9685_i2c.c.

#define PCA9685_LED3_ON_L_REG_ADDR   0X12

Definition at line 114 of file pca9685_i2c.c.

#define PCA9685_LED4_OFF_H_REG_ADDR   0X19

Definition at line 122 of file pca9685_i2c.c.

#define PCA9685_LED4_OFF_L_REG_ADDR   0X18

Definition at line 121 of file pca9685_i2c.c.

#define PCA9685_LED4_ON_H_REG_ADDR   0X17

Definition at line 120 of file pca9685_i2c.c.

#define PCA9685_LED4_ON_L_REG_ADDR   0X16

Definition at line 119 of file pca9685_i2c.c.

#define PCA9685_LED5_OFF_H_REG_ADDR   0X1D

Definition at line 127 of file pca9685_i2c.c.

#define PCA9685_LED5_OFF_L_REG_ADDR   0X1C

Definition at line 126 of file pca9685_i2c.c.

#define PCA9685_LED5_ON_H_REG_ADDR   0X1B

Definition at line 125 of file pca9685_i2c.c.

#define PCA9685_LED5_ON_L_REG_ADDR   0X1A

Definition at line 124 of file pca9685_i2c.c.

#define PCA9685_LED6_OFF_H_REG_ADDR   0X21

Definition at line 132 of file pca9685_i2c.c.

#define PCA9685_LED6_OFF_L_REG_ADDR   0X20

Definition at line 131 of file pca9685_i2c.c.

#define PCA9685_LED6_ON_H_REG_ADDR   0X1F

Definition at line 130 of file pca9685_i2c.c.

#define PCA9685_LED6_ON_L_REG_ADDR   0X1E

Definition at line 129 of file pca9685_i2c.c.

#define PCA9685_LED7_OFF_H_REG_ADDR   0X25

Definition at line 137 of file pca9685_i2c.c.

#define PCA9685_LED7_OFF_L_REG_ADDR   0X24

Definition at line 136 of file pca9685_i2c.c.

#define PCA9685_LED7_ON_H_REG_ADDR   0X23

Definition at line 135 of file pca9685_i2c.c.

#define PCA9685_LED7_ON_L_REG_ADDR   0X22

Definition at line 134 of file pca9685_i2c.c.

#define PCA9685_LED8_OFF_H_REG_ADDR   0X29

Definition at line 143 of file pca9685_i2c.c.

#define PCA9685_LED8_OFF_L_REG_ADDR   0X28

Definition at line 142 of file pca9685_i2c.c.

#define PCA9685_LED8_ON_H_REG_ADDR   0X27

Definition at line 141 of file pca9685_i2c.c.

#define PCA9685_LED8_ON_L_REG_ADDR   0X26

Definition at line 140 of file pca9685_i2c.c.

#define PCA9685_LED9_OFF_H_REG_ADDR   0X2D

Definition at line 148 of file pca9685_i2c.c.

#define PCA9685_LED9_OFF_L_REG_ADDR   0X2C

Definition at line 147 of file pca9685_i2c.c.

#define PCA9685_LED9_ON_H_REG_ADDR   0X2B

Definition at line 146 of file pca9685_i2c.c.

#define PCA9685_LED9_ON_L_REG_ADDR   0X2A

Definition at line 145 of file pca9685_i2c.c.

#define PCA9685_MODE1_REG_ADDR   0x00

Definition at line 95 of file pca9685_i2c.c.

Referenced by pca9685_i2c_init().

#define PCA9685_MODE2_REG_ADDR   0x01

Definition at line 96 of file pca9685_i2c.c.

#define PCA9685_PRESCALER_REG_ADDR   0XFE

Definition at line 185 of file pca9685_i2c.c.

Referenced by pca9685_i2c_init().

#define PCA9865_ALLCALL_BIT   0

Definition at line 192 of file pca9685_i2c.c.

Referenced by pca9685_i2c_init().

#define PCA9865_AUTO_INCREMENT_BIT   5

Definition at line 190 of file pca9685_i2c.c.

Referenced by pca9685_i2c_init().

#define PCA9865_OUTDRV_BIT   2

Definition at line 194 of file pca9685_i2c.c.

#define PCA9865_RESTART_BIT   7

Definition at line 189 of file pca9685_i2c.c.

Referenced by pca9685_i2c_init().

#define PCA9865_SLEEP_BIT   4

Definition at line 191 of file pca9685_i2c.c.

Referenced by pca9685_i2c_init().

#define PCA9865_SRV_DEFAULT_VAL_US   1000.

Definition at line 71 of file pca9685_i2c.c.

Referenced by pca9685_i2c_init().

#define PCA9865_SRV_NUMBER   16

Definition at line 75 of file pca9685_i2c.c.

Referenced by pca9685_i2c_init().

#define PCA9865_SRV_RESOLUTION   1.

Definition at line 67 of file pca9685_i2c.c.

Referenced by pca9685_i2c_init(), and pca9865_set_servo().

Enumeration Type Documentation

anonymous enum
Enumerator
PCA9685_I2C_STATUS_UNINIT 
PCA9685_I2C_STATUS_INITIALIZED 
PCA9865_I2C_STATUS_WRITE_LED_REG_BUSY 
PCA9865_I2C_STATUS_WRITE_LED_REG_READY 
PCA9865_I2C_STATUS_READ_LED_REG_BUSY 
PCA9865_I2C_STATUS_CHANGE_LED_REG_FINISHED 

Definition at line 214 of file pca9685_i2c.c.

Function Documentation

bool pca9865_set_servo ( uint8_t  srv_nb,
uint16_t  srv_val 
)

Definition at line 262 of file pca9685_i2c.c.

References FALSE, and PCA9865_SRV_RESOLUTION.

Referenced by pca9685_i2c_init().

+ Here is the caller graph for this function:

Variable Documentation

uint8_t pca9685_i2c_status = 0

Definition at line 224 of file pca9685_i2c.c.

struct i2c_transaction pca9685_i2c_trans

Definition at line 223 of file pca9685_i2c.c.

Referenced by pca9685_i2c_event(), pca9685_i2c_init(), and pca9685_i2c_periodic().

uint8_t pca9865_reg_nb[16]

Definition at line 231 of file pca9685_i2c.c.

uint16_t pca9865_write_servo_vals[PCA9865_SRV_NUMBER]

Definition at line 226 of file pca9685_i2c.c.

uint8_t srv_cnt = 0

Definition at line 225 of file pca9685_i2c.c.

Referenced by pca9685_i2c_event(), pca9685_i2c_init(), and pca9685_i2c_periodic().