|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
58 #define BUF2INT(_buf,_idx) ((int16_t)((_buf[_idx+1]<<8) | _buf[_idx]))
59 #define INT2BUF(_int,_buf,_idx) { _buf[_idx] = _int; _buf[_idx+1] = (_int>>8); }
61 #ifndef PCA9685_I2C_DEV
62 #define PCA9685_I2C_DEV i2c2
66 #ifndef PCA9865_SRV_RESOLUTION
67 #define PCA9865_SRV_RESOLUTION 1. // in microseconds
70 #ifndef PCA9865_SRV_DEFAULT_VAL_US
71 #define PCA9865_SRV_DEFAULT_VAL_US 1000. // in microseconds
74 #ifndef PCA9865_SRV_NUMBER
75 #define PCA9865_SRV_NUMBER 16 // in microseconds
79 #ifndef PCA9685_I2C_SLAVE_ADDR
80 #define PCA9685_I2C_SLAVE_ADDR 0xE0
84 #ifndef PCA9685_I2C_ALLCALL_ADDR
85 #define PCA9685_I2C_ALLCALL_ADDR 0xE0
87 #ifndef PCA9685_I2C_RESET_ADDR
88 #define PCA9685_I2C_RESET_ADDR 0x06
90 #ifndef PCA9685_I2C_GEN_CALL_ADDR
91 #define PCA9685_I2C_GEN_CALL_ADDR 0x00
95 #define PCA9685_MODE1_REG_ADDR 0x00
96 #define PCA9685_MODE2_REG_ADDR 0x01
97 #define PCA9685_ALLCALL_ADDR 0x05
99 #define PCA9685_LED0_ON_L_REG_ADDR 0X06
100 #define PCA9685_LED0_ON_H_REG_ADDR 0X07
101 #define PCA9685_LED0_OFF_L_REG_ADDR 0X08
102 #define PCA9685_LED0_OFF_H_REG_ADDR 0X09
104 #define PCA9685_LED1_ON_L_REG_ADDR 0X0A
105 #define PCA9685_LED1_ON_H_REG_ADDR 0X0B
106 #define PCA9685_LED1_OFF_L_REG_ADDR 0X0C
107 #define PCA9685_LED1_OFF_H_REG_ADDR 0X0D
109 #define PCA9685_LED2_ON_L_REG_ADDR 0X0E
110 #define PCA9685_LED2_ON_H_REG_ADDR 0X0F
111 #define PCA9685_LED2_OFF_L_REG_ADDR 0X10
112 #define PCA9685_LED2_OFF_H_REG_ADDR 0X11
114 #define PCA9685_LED3_ON_L_REG_ADDR 0X12
115 #define PCA9685_LED3_ON_H_REG_ADDR 0X13
116 #define PCA9685_LED3_OFF_L_REG_ADDR 0X14
117 #define PCA9685_LED3_OFF_H_REG_ADDR 0X15
119 #define PCA9685_LED4_ON_L_REG_ADDR 0X16
120 #define PCA9685_LED4_ON_H_REG_ADDR 0X17
121 #define PCA9685_LED4_OFF_L_REG_ADDR 0X18
122 #define PCA9685_LED4_OFF_H_REG_ADDR 0X19
124 #define PCA9685_LED5_ON_L_REG_ADDR 0X1A
125 #define PCA9685_LED5_ON_H_REG_ADDR 0X1B
126 #define PCA9685_LED5_OFF_L_REG_ADDR 0X1C
127 #define PCA9685_LED5_OFF_H_REG_ADDR 0X1D
129 #define PCA9685_LED6_ON_L_REG_ADDR 0X1E
130 #define PCA9685_LED6_ON_H_REG_ADDR 0X1F
131 #define PCA9685_LED6_OFF_L_REG_ADDR 0X20
132 #define PCA9685_LED6_OFF_H_REG_ADDR 0X21
134 #define PCA9685_LED7_ON_L_REG_ADDR 0X22
135 #define PCA9685_LED7_ON_H_REG_ADDR 0X23
136 #define PCA9685_LED7_OFF_L_REG_ADDR 0X24
137 #define PCA9685_LED7_OFF_H_REG_ADDR 0X25
140 #define PCA9685_LED8_ON_L_REG_ADDR 0X26
141 #define PCA9685_LED8_ON_H_REG_ADDR 0X27
142 #define PCA9685_LED8_OFF_L_REG_ADDR 0X28
143 #define PCA9685_LED8_OFF_H_REG_ADDR 0X29
145 #define PCA9685_LED9_ON_L_REG_ADDR 0X2A
146 #define PCA9685_LED9_ON_H_REG_ADDR 0X2B
147 #define PCA9685_LED9_OFF_L_REG_ADDR 0X2C
148 #define PCA9685_LED9_OFF_H_REG_ADDR 0X2D
150 #define PCA9685_LED10_ON_L_REG_ADDR 0X2E
151 #define PCA9685_LED10_ON_H_REG_ADDR 0X2F
152 #define PCA9685_LED10_OFF_L_REG_ADDR 0X30
153 #define PCA9685_LED10_OFF_H_REG_ADDR 0X31
155 #define PCA9685_LED11_ON_L_REG_ADDR 0X32
156 #define PCA9685_LED11_ON_H_REG_ADDR 0X33
157 #define PCA9685_LED11_OFF_L_REG_ADDR 0X34
158 #define PCA9685_LED11_OFF_H_REG_ADDR 0X35
160 #define PCA9685_LED12_ON_L_REG_ADDR 0X36
161 #define PCA9685_LED12_ON_H_REG_ADDR 0X37
162 #define PCA9685_LED12_OFF_L_REG_ADDR 0X38
163 #define PCA9685_LED12_OFF_H_REG_ADDR 0X39
165 #define PCA9685_LED13_ON_L_REG_ADDR 0X3A
166 #define PCA9685_LED13_ON_H_REG_ADDR 0X3B
167 #define PCA9685_LED13_OFF_L_REG_ADDR 0X3C
168 #define PCA9685_LED13_OFF_H_REG_ADDR 0X3D
170 #define PCA9685_LED14_ON_L_REG_ADDR 0X3E
171 #define PCA9685_LED14_ON_H_REG_ADDR 0X3F
172 #define PCA9685_LED14_OFF_L_REG_ADDR 0X40
173 #define PCA9685_LED14_OFF_H_REG_ADDR 0X41
175 #define PCA9685_LED15_ON_L_REG_ADDR 0X42
176 #define PCA9685_LED15_ON_H_REG_ADDR 0X43
177 #define PCA9685_LED15_OFF_L_REG_ADDR 0X44
178 #define PCA9685_LED15_OFF_H_REG_ADDR 0X45
180 #define PCA9685_ALL_LED_ON_L_REG_ADDR 0XFA
181 #define PCA9685_ALL_LED_ON_H_REG_ADDR 0XFB
182 #define PCA9685_ALL_LED_OFF_L_REG_ADDR 0XFC
183 #define PCA9685_ALL_LED_OFF_H_REG_ADDR 0XFD
185 #define PCA9685_PRESCALER_REG_ADDR 0XFE
189 #define PCA9865_RESTART_BIT 7 // 1= RESTART ENABLE, DEFAULT = 0
190 #define PCA9865_AUTO_INCREMENT_BIT 5 // 1 = AUTO INCREMENT, DEFAULT = 0
191 #define PCA9865_SLEEP_BIT 4 // 1 = LOW POWER MODE (OSC OFF), 0=NORMAL MODE, DEFAULT=0
192 #define PCA9865_ALLCALL_BIT 0 // 1 = ALL LED ENABLE, DEFAULT = 1
194 #define PCA9865_OUTDRV_BIT 2 // 1 = TOTEM POLE, 0 = OPEN DRAIN, DEFAULT = 1
203 #if defined(PCA9685_SEND_SERVO_VALUES) && PCA9685_SEND_SERVO_VALUES == 1
204 static void pca9685_send_servo_values(
struct transport_tx *trans,
struct link_device *
dev);
227 #if defined(PCA9685_SEND_SERVO_VALUES) && PCA9685_SEND_SERVO_VALUES == 1
228 PRINT_CONFIG_MSG(
"PCA9685 servo values can be found in the ""BARO_WORDS"" message")
239 #if defined(PCA9685_SEND_SERVO_VALUES) && PCA9685_SEND_SERVO_VALUES == 1
240 static void pca9685_send_servo_values(
struct transport_tx *trans,
struct link_device *
dev)
245 pprz_msg_send_CSC_SERVO_CMD(
247 &pca9865_read_servo_vals[0], &pca9865_read_servo_vals[1],
248 &pca9865_read_servo_vals[2], &pca9865_read_servo_vals[3]
288 #if defined(PCA9685_SEND_SERVO_VALUES) && PCA9685_SEND_SERVO_VALUES == 1
289 pca9865_read_servo_vals[
srv_cnt] = 0;
314 if (reg_value > 0xFF) { reg_value = 0xFF; }
359 #if defined(PCA9685_SEND_SERVO_VALUES) && PCA9685_SEND_SERVO_VALUES == 1
436 #if defined(PCA9685_SEND_SERVO_VALUES) && PCA9685_SEND_SERVO_VALUES == 1
466 #endif // #if !defined(SITL)
#define PCA9865_AUTO_INCREMENT_BIT
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
#define PCA9865_SRV_DEFAULT_VAL_US
uint16_t pca9865_write_servo_vals[PCA9865_SRV_NUMBER]
uint8_t pca9685_i2c_status
#define PCA9685_ALL_LED_ON_L_REG_ADDR
#define PCA9865_SLEEP_BIT
Paparazzi fixed point algebra.
@ PCA9865_I2C_STATUS_CHANGE_LED_REG_FINISHED
#define PCA9685_I2C_GEN_CALL_ADDR
@ I2CTransSuccess
transaction successfully finished by I2C driver
void pca9685_i2c_init(void)
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
bool i2c_transmit(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len)
Submit a write only transaction.
bool pca9865_set_servo(uint8_t srv_nb, uint16_t srv_val)
@ PCA9685_I2C_STATUS_UNINIT
volatile uint32_t nb_tick
SYS_TIME_TICKS since startup.
#define PCA9685_PRESCALER_REG_ADDR
#define PCA9865_ALLCALL_BIT
static const struct usb_device_descriptor dev
bool i2c_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction.
@ PCA9865_I2C_STATUS_WRITE_LED_REG_READY
Architecture independent timing functions.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
@ PCA9685_I2C_STATUS_INITIALIZED
uint8_t pca9865_reg_nb[16]
enum I2CTransactionStatus status
Transaction status.
#define PCA9685_I2C_SLAVE_ADDR
I2C transaction structure.
@ PCA9865_I2C_STATUS_READ_LED_REG_BUSY
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
#define PCA9685_MODE1_REG_ADDR
#define BUF2INT(_buf, _idx)
@ I2CTransPending
transaction is pending in queue
#define PCA9865_RESTART_BIT
#define SYS_TIME_FREQUENCY
(Default) sys_time timer frequency in Hz.
#define PCA9685_I2C_RESET_ADDR
@ I2CTransDone
transaction set to done by user level
#define PCA9865_SRV_RESOLUTION
#define PCA9685_I2C_ALLCALL_ADDR
#define PCA9865_SRV_NUMBER
struct i2c_transaction pca9685_i2c_trans
void pca9685_i2c_periodic(void)
#define DefaultPeriodic
Set default periodic telemetry.
Paparazzi atmospheric pressure conversion utilities.
void pca9685_i2c_event(void)
@ PCA9865_I2C_STATUS_WRITE_LED_REG_BUSY