Example #1
0
File: ecezo.c Project: g-vidal/upm
void ecezo_close(ecezo_context dev)
{
    assert(dev != NULL);

    if (dev->uart)
        mraa_uart_stop(dev->uart);
    if (dev->i2c)
        mraa_i2c_stop(dev->i2c);

    free(dev);
}
Example #2
0
mrb_value mrb_mraa_uart_stop(mrb_state *mrb, mrb_value self) {
  mraa_uart_context uart;
  mraa_result_t result;

  uart = (mraa_uart_context)mrb_data_get_ptr(mrb, self, &mrb_mraa_uart_ctx_type);

  result = mraa_uart_stop(uart);
  if (result != MRAA_SUCCESS) {
    mrb_raise(mrb, E_RUNTIME_ERROR, "Could not stop port");
  }
  return self;
}
Example #3
0
void rn2903_close(rn2903_context dev)
{
    assert(dev != NULL);

    if (dev->to_hex_buf)
        free(dev->to_hex_buf);
    if (dev->from_hex_buf)
        free(dev->from_hex_buf);

    if (dev->uart)
        mraa_uart_stop(dev->uart);

    free(dev);
}
Example #4
0
File: uart.hpp Project: emutex/mraa
 /**
  * Uart destructor
  */
 ~Uart()
 {
     mraa_uart_stop(m_uart);
 }
Example #5
0
int main()
{
    int sampleCount = 0;
    int sampleRate = 0;
    uint64_t rateTimer;
    uint64_t displayTimer;
    uint64_t now;

    //  Using RTIMULib here allows it to use the .ini file generated by RTIMULibDemo.
    //  Or, you can create the .ini in some other directory by using:
    //      RTIMUSettings *settings = new RTIMUSettings("<directory path>", "RTIMULib");
    //  where <directory path> is the path to where the .ini file is to be loaded/saved

    RTIMUSettings *settings = new RTIMUSettings("RTIMULib");

    RTIMU *imu = RTIMU::createIMU(settings);

    if ((imu == NULL) || (imu->IMUType() == RTIMU_TYPE_NULL)) {
        printf("No IMU found\n");
        exit(1);
    }

    //  This is an opportunity to manually override any settings before the call IMUInit

    //  set up IMU

    imu->IMUInit();

    //  this is a convenient place to change fusion parameters

    imu->setSlerpPower(0.02);
    imu->setGyroEnable(true);
    imu->setAccelEnable(true);
    imu->setCompassEnable(true);


    // Set up serial out UART ports
    mraa_uart_context uart;
    //uart = mraa_uart_init(0);
    uart=mraa_uart_init_raw("/dev/ttyGS0");
	mraa_uart_set_baudrate(uart, 9600);
	if (uart == NULL) {
		fprintf(stderr, "UART failed to setup\n");
		return 0;
	}
	char buffer[20]={}; // To hold output



    while (1) {

        while (imu->IMURead()) {
            RTIMU_DATA imuData = imu->getIMUData();

            	//sleep(1);
                printf("%s\r", RTMath::displayDegrees("Gyro", imuData.fusionPose) );
                //printf("\nx %f ",imuData.gyro.x()*(180.0/3.14));
                //printf("\ny %f ",imuData.gyro.y()*(180.0/3.14));
                //printf("\nz %f\n",imuData.gyro.z()*(180.0/3.14));

                sprintf(buffer,"%4f\n",imuData.fusionPose.x()*(180.0/3.14));
                mraa_uart_write(uart, buffer, sizeof(buffer));

                printf("\n\n");
                //imuData.
                fflush(stdout);
                //displayTimer = now;



        }

    }
    mraa_uart_stop(uart);
  	mraa_deinit();
}
Example #6
0
void serial_close(void){
mraa_uart_stop(uart);
mraa_deinit();}