maa: change struct names to be more unique and fix allocs
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -29,15 +29,16 @@
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
fprintf(stdout, "MAA Version: %d\n Starting Blinking on IO8", maa_get_version());
|
||||
gpio_t gpio;
|
||||
maa_gpio_init(&gpio, 26);
|
||||
maa_gpio_dir(&gpio, "out");
|
||||
fprintf(stdout, "MAA Version: %d\nStarting Blinking on IO8\n",
|
||||
maa_get_version());
|
||||
maa_gpio_context* gpio;
|
||||
gpio = maa_gpio_init(26);
|
||||
maa_gpio_dir(gpio, "out");
|
||||
|
||||
while (1){
|
||||
maa_gpio_write(&gpio, 0);
|
||||
while (1) {
|
||||
maa_gpio_write(gpio, 0);
|
||||
sleep(1);
|
||||
maa_gpio_write(&gpio, 1);
|
||||
maa_gpio_write(gpio, 1);
|
||||
sleep(1);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -29,21 +29,24 @@
|
||||
int
|
||||
main ()
|
||||
{
|
||||
pwm_t pwm;
|
||||
maa_pwm_init(&pwm, 0, 3);
|
||||
maa_pwm_period_us(&pwm, 200);
|
||||
maa_pwm_enable(&pwm, 1);
|
||||
maa_pwm_context* pwm;
|
||||
pwm = maa_pwm_init(0, 3);
|
||||
if (pwm == NULL) {
|
||||
return 1;
|
||||
}
|
||||
maa_pwm_period_us(pwm, 200);
|
||||
maa_pwm_enable(pwm, 1);
|
||||
|
||||
float value = 0.0f;
|
||||
|
||||
while(1) {
|
||||
while (1) {
|
||||
value = value + 0.01f;
|
||||
maa_pwm_write(&pwm, value);
|
||||
maa_pwm_write(pwm, value);
|
||||
usleep(50000);
|
||||
if (value >= 1.0f) {
|
||||
value = 0.0f;
|
||||
}
|
||||
float output = maa_pwm_read(&pwm);
|
||||
float output = maa_pwm_read(pwm);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -76,31 +76,31 @@
|
||||
#define SCALE_4_35_MG 4.35
|
||||
|
||||
int
|
||||
main ()
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
float direction = 0;
|
||||
int16_t x = 0, y = 0, z = 0;
|
||||
char rx_tx_buf[MAX_BUFFER_LENGTH];
|
||||
|
||||
i2c_t i2c;
|
||||
maa_i2c_init(&i2c);
|
||||
maa_i2c_context *i2c;
|
||||
i2c = maa_i2c_init();
|
||||
|
||||
maa_i2c_address(&i2c, HMC5883L_I2C_ADDR);
|
||||
maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
rx_tx_buf[0] = HMC5883L_CONF_REG_B;
|
||||
rx_tx_buf[1] = GA_1_3_REG;
|
||||
maa_i2c_write(&i2c, rx_tx_buf, 2);
|
||||
maa_i2c_write(i2c, rx_tx_buf, 2);
|
||||
|
||||
maa_i2c_address(&i2c, HMC5883L_I2C_ADDR);
|
||||
maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
rx_tx_buf[0] = HMC5883L_MODE_REG;
|
||||
rx_tx_buf[1] = HMC5883L_CONT_MODE;
|
||||
maa_i2c_write(&i2c, rx_tx_buf, 2);
|
||||
maa_i2c_write(i2c, rx_tx_buf, 2);
|
||||
|
||||
for(;;) {
|
||||
maa_i2c_address(&i2c, HMC5883L_I2C_ADDR);
|
||||
maa_i2c_write_byte(&i2c, HMC5883L_DATA_REG);
|
||||
maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
maa_i2c_write_byte(i2c, HMC5883L_DATA_REG);
|
||||
|
||||
maa_i2c_address(&i2c, HMC5883L_I2C_ADDR);
|
||||
maa_i2c_read(&i2c, rx_tx_buf, DATA_REG_SIZE);
|
||||
maa_i2c_address(i2c, HMC5883L_I2C_ADDR);
|
||||
maa_i2c_read(i2c, rx_tx_buf, DATA_REG_SIZE);
|
||||
|
||||
x = (rx_tx_buf[HMC5883L_X_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_X_LSB_REG] ;
|
||||
z = (rx_tx_buf[HMC5883L_Z_MSB_REG] << 8 ) | rx_tx_buf[HMC5883L_Z_LSB_REG] ;
|
||||
|
||||
Reference in New Issue
Block a user