MAA version 0.2.0 moves to a standard C API
* Removed all C++ code and renamed all .cxx extensions to .c * All functions are renamed to maa_ and modules are for example called maa_pwm * Cmake can now 'make doc' using a Doxyfile.in to create documentation * examples/ have been updated but swig generated API is untested Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
add_executable (i2c_HMC5883L i2c_HMC5883L.cxx)
|
||||
add_executable (hellomaa hellomaa.cxx)
|
||||
add_executable (cycle-pwm3 cycle-pwm3.cxx)
|
||||
add_executable (i2c_HMC5883L i2c_HMC5883L.c)
|
||||
add_executable (hellomaa hellomaa.c)
|
||||
add_executable (cycle-pwm3 cycle-pwm3.c)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/api ${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
target_link_libraries (hellomaa maa)
|
||||
target_link_libraries (i2c_HMC5883L maa)
|
||||
target_link_libraries (i2c_HMC5883L maa m)
|
||||
target_link_libraries (cycle-pwm3 maa)
|
||||
|
||||
@@ -29,20 +29,21 @@
|
||||
int
|
||||
main ()
|
||||
{
|
||||
maa::PWM pwm(0, 3);
|
||||
pwm.period_us(200);
|
||||
pwm.enable(1);
|
||||
pwm_t pwm;
|
||||
maa_pwm_init(&pwm, 0, 3);
|
||||
maa_pwm_period_us(&pwm, 200);
|
||||
maa_pwm_enable(&pwm, 1);
|
||||
|
||||
float value = 0.0f;
|
||||
|
||||
while(1) {
|
||||
value = value + 0.01f;
|
||||
pwm.write(value);
|
||||
maa_pwm_write(&pwm, value);
|
||||
usleep(50000);
|
||||
if (value >= 1.0f) {
|
||||
value = 0.0f;
|
||||
}
|
||||
float output = pwm.read();
|
||||
float output = maa_pwm_read(&pwm);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -29,6 +29,6 @@
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
fprintf(stdout, "hello maa\n Version: %d\n", get_version());
|
||||
fprintf(stdout, "hello maa\n Version: %d\n", maa_get_version());
|
||||
return 0;
|
||||
}
|
||||
@@ -82,24 +82,25 @@ main ()
|
||||
int16_t x = 0, y = 0, z = 0;
|
||||
char rx_tx_buf[MAX_BUFFER_LENGTH];
|
||||
|
||||
maa::I2CSlave i2c(26, 27);
|
||||
i2c_t i2c;
|
||||
maa_i2c_init(&i2c);
|
||||
|
||||
i2c.address(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;
|
||||
i2c.write(rx_tx_buf, 2);
|
||||
maa_i2c_write(&i2c, rx_tx_buf, 2);
|
||||
|
||||
i2c.address(HMC5883L_I2C_ADDR);
|
||||
maa_i2c_address(&i2c, HMC5883L_I2C_ADDR);
|
||||
rx_tx_buf[0] = HMC5883L_MODE_REG;
|
||||
rx_tx_buf[1] = HMC5883L_CONT_MODE;
|
||||
i2c.write(rx_tx_buf, 2);
|
||||
maa_i2c_write(&i2c, rx_tx_buf, 2);
|
||||
|
||||
for(;;) {
|
||||
i2c.address(HMC5883L_I2C_ADDR);
|
||||
i2c.write(HMC5883L_DATA_REG);
|
||||
maa_i2c_address(&i2c, HMC5883L_I2C_ADDR);
|
||||
maa_i2c_write_byte(&i2c, HMC5883L_DATA_REG);
|
||||
|
||||
i2c.address(HMC5883L_I2C_ADDR);
|
||||
i2c.read(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