pca9685 pcf8591 ms561101ba03 update
This commit is contained in:
parent
e7d619b882
commit
dd072bd7db
9 changed files with 109 additions and 96 deletions
|
|
@ -13,18 +13,20 @@
|
|||
#include <i2c/i2c.h>
|
||||
#include <ms561101ba03/ms561101ba03.h>
|
||||
|
||||
#define I2C_BUS 0
|
||||
#define SCL_PIN 5
|
||||
#define SDA_PIN 4
|
||||
|
||||
void user_init(void)
|
||||
{
|
||||
i2c_init(SCL_PIN, SDA_PIN);
|
||||
i2c_init(I2C_BUS, SCL_PIN, SDA_PIN, I2C_FREQ_100K);
|
||||
|
||||
uart_set_baud(0, 115200);
|
||||
printf("SDK version:%s\n\n", sdk_system_get_sdk_version());
|
||||
|
||||
ms561101ba03_t device = {
|
||||
.addr = MS561101BA03_ADDR_CSB_LOW,
|
||||
.i2c_dev.bus = I2C_BUS,
|
||||
.i2c_dev.addr = MS561101BA03_ADDR_CSB_LOW,
|
||||
.osr = MS561101BA03_OSR_4096,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@
|
|||
#include <pca9685/pca9685.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define ADDR 0x40
|
||||
#define ADDR PCA9685_ADDR_BASE
|
||||
|
||||
#define I2C_BUS 0
|
||||
#define SCL_PIN 5
|
||||
#define SDA_PIN 4
|
||||
|
||||
|
|
@ -23,19 +24,23 @@ void user_init(void)
|
|||
uart_set_baud(0, 115200);
|
||||
printf("SDK version:%s\n", sdk_system_get_sdk_version());
|
||||
|
||||
i2c_init(SCL_PIN, SDA_PIN);
|
||||
i2c_init(I2C_BUS, SCL_PIN, SDA_PIN, I2C_FREQ_100K);
|
||||
i2c_dev_t dev = {
|
||||
.addr = ADDR,
|
||||
.bus = I2C_BUS,
|
||||
};
|
||||
|
||||
pca9685_init(ADDR);
|
||||
pca9685_init(&dev);
|
||||
|
||||
pca9685_set_pwm_frequency(ADDR, 1000);
|
||||
printf("Freq 1000Hz, real %d\n", pca9685_get_pwm_frequency(ADDR));
|
||||
pca9685_set_pwm_frequency(&dev, 1000);
|
||||
printf("Freq 1000Hz, real %d\n", pca9685_get_pwm_frequency(&dev));
|
||||
|
||||
uint16_t val = 0;
|
||||
while (true)
|
||||
{
|
||||
printf("Set ch0 to %d, ch4 to %d\n", val, 4096 - val);
|
||||
pca9685_set_pwm_value(ADDR, 0, val);
|
||||
pca9685_set_pwm_value(ADDR, 4, 4096 - val);
|
||||
pca9685_set_pwm_value(&dev, 0, val);
|
||||
pca9685_set_pwm_value(&dev, 4, 4096 - val);
|
||||
|
||||
if (val++ == 4096)
|
||||
val = 0;
|
||||
|
|
|
|||
|
|
@ -9,15 +9,21 @@
|
|||
#include "i2c/i2c.h"
|
||||
#include "pcf8591/pcf8591.h"
|
||||
|
||||
#define ADDR PCF8591_DEFAULT_ADDRESS
|
||||
#define I2C_BUS 0
|
||||
#define SCL_PIN 5
|
||||
#define SDA_PIN 4
|
||||
|
||||
static void measure(void *pvParameters)
|
||||
{
|
||||
i2c_dev_t dev = {
|
||||
.addr = ADDR,
|
||||
.bus = I2C_BUS,
|
||||
};
|
||||
while (1)
|
||||
{
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
printf("Value: %d\n", pcf8591_read(PCF8591_DEFAULT_ADDRESS, 0x03));
|
||||
printf("Value: %d\n", pcf8591_read(&dev, 0x03));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -30,7 +36,7 @@ void user_init(void)
|
|||
printf("SDK version : %s\n", sdk_system_get_sdk_version());
|
||||
printf("GIT version : %s\n", GITSHORTREV);
|
||||
|
||||
i2c_init(SCL_PIN, SDA_PIN);
|
||||
i2c_init(I2C_BUS, SCL_PIN, SDA_PIN, I2C_FREQ_100K);
|
||||
|
||||
xTaskCreate(measure, "measure_task", 256, NULL, 2, NULL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue