trikRuntime
usbMSP430Interface.cpp File Reference
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <QtCore/QByteArray>
#include <QtCore/QString>
#include <QtCore/QObject>
#include <QtCore/QThread>
#include <QsLog.h>
#include "usbMSP430Defines.h"
#include "usbMSP430Interface.h"
Include dependency graph for usbMSP430Interface.cpp:

Classes

class  Sleeper
 Delays class. More...
 

Functions

uint32_t hex2num (char *string, uint16_t pos, uint16_t numsize)
 Extract number from packet. More...
 
void makeWriteRegPacket (char *msp_packet, uint8_t dev_addr, uint8_t reg_addr, uint32_t reg_val)
 Make write register packet. More...
 
void makeReadRegPacket (char *msp_packet, uint8_t dev_addr, uint8_t reg_addr)
 Make read register packet. More...
 
uint32_t decodeReceivedPacket (char *msp_packet, uint8_t &dev_addr, uint8_t &func_code, uint8_t &reg_addr, uint32_t &reg_val)
 Function for decoding received packet. More...
 
uint32_t init_USBTTYDevice ()
 Init USB TTY device. More...
 
uint32_t sendUSBPacket (char *in_msp_packet, char *out_msp_packet)
 Send USB packet. More...
 
uint32_t init_motors_USBMSP ()
 Init power motors. More...
 
uint32_t init_servomotors_USBMSP ()
 Init servo motors. More...
 
uint32_t init_encoders_USBMSP ()
 Init encoders. More...
 
uint32_t init_sensors_USBMSP ()
 Init sensors. More...
 
uint32_t init_dhtxx_sensors_USBMSP ()
 Init DHTxx sensors. More...
 
uint32_t init_i2c_sensors_USBMSP ()
 Init I2C sensors. More...
 
uint32_t connect_USBMSP ()
 Connect to USB MSP430 device. More...
 
uint32_t disconnect_USBMSP ()
 Disconnect from USB MSP430 device. More...
 
uint32_t power_Motor (QByteArray const &i2c_data)
 Motor power control function. More...
 
uint32_t freq_Motor (QByteArray const &i2c_data)
 Set motor frequency function. More...
 
uint32_t reset_Encoder (QByteArray const &i2c_data)
 Reset encoder function. More...
 
uint32_t read_Encoder (QByteArray const &i2c_data)
 Read encoder function. More...
 
uint32_t init_URM04 (uint8_t i2c_addr, uint8_t usart_addr)
 Init I2C + USART + URM04. More...
 
uint32_t read_URM04_dist (uint8_t dev_addr, uint8_t urm04_addr)
 Read URM04 distance function. More...
 
uint32_t read_Sensor (QByteArray const &i2c_data)
 Read sensor function. More...
 
uint32_t send_USBMSP (QByteArray const &i2c_data)
 Send data to MSP430 via USB. More...
 
uint32_t read_USBMSP (QByteArray const &i2c_data)
 Read data from MSP430 via USB. More...
 

Variables

volatile uint16_t mper
 
volatile uint16_t sper
 
int usb_out_descr
 
struct termios usb_tty
 
volatile uint8_t alt_func_flag
 
uint8_t addr_table_i2c_usb [84]
 

Function Documentation

uint32_t connect_USBMSP ( )

Connect to USB MSP430 device.

uint32_t decodeReceivedPacket ( char *  msp_packet,
uint8_t &  dev_addr,
uint8_t &  func_code,
uint8_t &  reg_addr,
uint32_t &  reg_val 
)

Function for decoding received packet.

uint32_t disconnect_USBMSP ( )

Disconnect from USB MSP430 device.

uint32_t freq_Motor ( QByteArray const &  i2c_data)

Set motor frequency function.

uint32_t hex2num ( char *  string,
uint16_t  pos,
uint16_t  numsize 
)

Extract number from packet.

uint32_t init_dhtxx_sensors_USBMSP ( )

Init DHTxx sensors.

uint32_t init_encoders_USBMSP ( )

Init encoders.

uint32_t init_i2c_sensors_USBMSP ( )

Init I2C sensors.

uint32_t init_motors_USBMSP ( )

Init power motors.

Init motors.

uint32_t init_sensors_USBMSP ( )

Init sensors.

uint32_t init_servomotors_USBMSP ( )

Init servo motors.

uint32_t init_URM04 ( uint8_t  i2c_addr,
uint8_t  usart_addr 
)

Init I2C + USART + URM04.

uint32_t init_USBTTYDevice ( )

Init USB TTY device.

void makeReadRegPacket ( char *  msp_packet,
uint8_t  dev_addr,
uint8_t  reg_addr 
)

Make read register packet.

void makeWriteRegPacket ( char *  msp_packet,
uint8_t  dev_addr,
uint8_t  reg_addr,
uint32_t  reg_val 
)

Make write register packet.

uint32_t power_Motor ( QByteArray const &  i2c_data)

Motor power control function.

uint32_t read_Encoder ( QByteArray const &  i2c_data)

Read encoder function.

uint32_t read_Sensor ( QByteArray const &  i2c_data)

Read sensor function.

uint32_t read_URM04_dist ( uint8_t  dev_addr,
uint8_t  urm04_addr 
)

Read URM04 distance function.

uint32_t read_USBMSP ( QByteArray const &  i2c_data)

Read data from MSP430 via USB.

uint32_t reset_Encoder ( QByteArray const &  i2c_data)

Reset encoder function.

uint32_t send_USBMSP ( QByteArray const &  i2c_data)

Send data to MSP430 via USB.

uint32_t sendUSBPacket ( char *  in_msp_packet,
char *  out_msp_packet 
)

Send USB packet.

Variable Documentation

uint8_t addr_table_i2c_usb[84]
Initial value:
=
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, MOTOR1, MOTOR2, MOTOR3, MOTOR4,
MOTOR1, MOTOR2, MOTOR4, MOTOR3, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, ENCODER1, ENCODER2,
ENCODER3, ENCODER4, 0, 0, 0, 0, 0, 0, 0, 0,
#define SPWM9
Definition: usbMSP430Defines.h:286
#define SPWM5
Definition: usbMSP430Defines.h:282
#define ENCODER2
Definition: usbMSP430Defines.h:254
#define MOTOR2
Definition: usbMSP430Defines.h:232
#define SPWM12
Definition: usbMSP430Defines.h:289
#define SPWM11
Definition: usbMSP430Defines.h:288
#define SPWM7
Definition: usbMSP430Defines.h:284
#define SPWM4
Definition: usbMSP430Defines.h:281
#define MOTOR4
Definition: usbMSP430Defines.h:234
#define I2C4
Definition: usbMSP430Defines.h:274
#define SPWM13
Definition: usbMSP430Defines.h:290
#define SENSOR4
Definition: usbMSP430Defines.h:238
#define SPWM6
Definition: usbMSP430Defines.h:283
#define SENSOR5
Definition: usbMSP430Defines.h:239
#define I2C1
Definition: usbMSP430Defines.h:271
#define MOTOR3
Definition: usbMSP430Defines.h:233
#define MOTOR1
USB devices addresses.
Definition: usbMSP430Defines.h:231
#define SENSOR3
Definition: usbMSP430Defines.h:237
#define I2C5
Definition: usbMSP430Defines.h:275
#define SPWM1
Definition: usbMSP430Defines.h:278
#define I2C3
Definition: usbMSP430Defines.h:273
#define SPWM2
Definition: usbMSP430Defines.h:279
#define SPWM14
Definition: usbMSP430Defines.h:291
#define I2C2
Definition: usbMSP430Defines.h:272
#define I2C6
Definition: usbMSP430Defines.h:276
#define ENCODER3
Definition: usbMSP430Defines.h:255
#define SPWM8
Definition: usbMSP430Defines.h:285
#define SENSOR6
Definition: usbMSP430Defines.h:240
#define SPWM3
Definition: usbMSP430Defines.h:280
#define SENSOR2
Definition: usbMSP430Defines.h:236
#define SENSOR1
Definition: usbMSP430Defines.h:235
#define I2C7
Definition: usbMSP430Defines.h:277
#define ENCODER1
Definition: usbMSP430Defines.h:253
#define SPWM10
Definition: usbMSP430Defines.h:287
#define SENSOR17
Definition: usbMSP430Defines.h:251
#define ENCODER4
Definition: usbMSP430Defines.h:256
volatile uint8_t alt_func_flag
volatile uint16_t mper
volatile uint16_t sper
int usb_out_descr
struct termios usb_tty