trikRuntime
usbMSP430Interface.h
Go to the documentation of this file.
1 /* Copyright 2015 Rostislav Varzar
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  * Created on: Fabruary 12, 2015
15  * Author: Rostislav Varzar
16 */
17 
18 #pragma once
19 
21 uint32_t hex2num(char *string // Input string
22  , uint16_t pos // Start position
23  , uint16_t numsize); // Number size
24 
26 void makeWriteRegPacket(char *msp_packet // Created packet string
27  , uint8_t dev_addr // Device address
28  , uint8_t reg_addr // Registers address to write
29  , uint32_t reg_val); // Value to write
30 
32 void makeReadRegPacket(char *msp_packet // Created packet string
33  , uint8_t dev_addr // Device address
34  , uint8_t reg_addr); // Register address to read
35 
37 uint32_t init_USBTTYDevice();
38 
40 uint32_t sendUSBPacket(char *in_msp_packet // Packet to send
41  , char *out_msp_packet); // Received packet
42 
44 uint32_t decodeReceivedPacket(char *msp_packet // Input MSP430 USB packet string
45  , uint8_t &dev_addr // Decoded response device address
46  , uint8_t &func_code // Decoded function number (read/write)
47  , uint8_t &reg_addr // Decoded register address
48  , uint32_t &reg_val); // Decoded register value
49 
51 uint32_t init_motors_USBMSP();
52 
54 uint32_t init_servomotors_USBMSP();
55 
57 uint32_t init_encoders_USBMSP();
58 
60 uint32_t init_sensors_USBMSP();
61 
63 uint32_t init_dhtxx_sensors_USBMSP();
64 
66 uint32_t init_i2c_sensors_USBMSP();
67 
69 uint32_t power_Motor(QByteArray const &i2c_data);
70 
72 uint32_t freq_Motor(QByteArray const &i2c_data);
73 
75 uint32_t reset_Encoder(QByteArray const &i2c_data);
76 
78 uint32_t read_Encoder(QByteArray const &i2c_data);
79 
81 uint32_t read_Sensor(QByteArray const &i2c_data);
82 
84 uint32_t init_URM04(uint8_t i2c_addr, uint8_t usart_addr);
85 
87 uint32_t read_URM04_dist(uint8_t dev_addr, uint8_t urm04_addr);
88 
90 uint32_t connect_USBMSP();
91 
93 uint32_t disconnect_USBMSP();
94 
96 uint32_t send_USBMSP(QByteArray const &i2c_data);
97 
99 uint32_t read_USBMSP(QByteArray const &i2c_data);
100 
uint32_t init_encoders_USBMSP()
Init encoders.
Definition: usbMSP430Interface.cpp:297
void makeReadRegPacket(char *msp_packet, uint8_t dev_addr, uint8_t reg_addr)
Make read register packet.
Definition: usbMSP430Interface.cpp:93
uint32_t init_dhtxx_sensors_USBMSP()
Init DHTxx sensors.
Definition: usbMSP430Interface.cpp:350
uint32_t init_sensors_USBMSP()
Init sensors.
Definition: usbMSP430Interface.cpp:313
void makeWriteRegPacket(char *msp_packet, uint8_t dev_addr, uint8_t reg_addr, uint32_t reg_val)
Make write register packet.
Definition: usbMSP430Interface.cpp:80
uint32_t freq_Motor(QByteArray const &i2c_data)
Set motor frequency function.
Definition: usbMSP430Interface.cpp:579
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.
Definition: usbMSP430Interface.cpp:102
uint32_t read_USBMSP(QByteArray const &i2c_data)
Read data from MSP430 via USB.
Definition: usbMSP430Interface.cpp:1144
uint32_t reset_Encoder(QByteArray const &i2c_data)
Reset encoder function.
Definition: usbMSP430Interface.cpp:612
uint32_t send_USBMSP(QByteArray const &i2c_data)
Send data to MSP430 via USB.
Definition: usbMSP430Interface.cpp:1126
uint32_t connect_USBMSP()
Connect to USB MSP430 device.
Definition: usbMSP430Interface.cpp:435
uint32_t init_i2c_sensors_USBMSP()
Init I2C sensors.
Definition: usbMSP430Interface.cpp:391
uint32_t init_USBTTYDevice()
Init USB TTY device.
Definition: usbMSP430Interface.cpp:135
uint32_t power_Motor(QByteArray const &i2c_data)
Motor power control function.
Definition: usbMSP430Interface.cpp:486
uint32_t sendUSBPacket(char *in_msp_packet, char *out_msp_packet)
Send USB packet.
Definition: usbMSP430Interface.cpp:174
uint32_t read_Sensor(QByteArray const &i2c_data)
Read sensor function.
Definition: usbMSP430Interface.cpp:758
uint32_t init_motors_USBMSP()
Init motors.
Definition: usbMSP430Interface.cpp:227
uint32_t hex2num(char *string, uint16_t pos, uint16_t numsize)
Extract number from packet.
Definition: usbMSP430Interface.cpp:63
uint32_t read_URM04_dist(uint8_t dev_addr, uint8_t urm04_addr)
Read URM04 distance function.
Definition: usbMSP430Interface.cpp:702
uint32_t init_URM04(uint8_t i2c_addr, uint8_t usart_addr)
Init I2C + USART + URM04.
Definition: usbMSP430Interface.cpp:689
uint32_t read_Encoder(QByteArray const &i2c_data)
Read encoder function.
Definition: usbMSP430Interface.cpp:644
uint32_t disconnect_USBMSP()
Disconnect from USB MSP430 device.
Definition: usbMSP430Interface.cpp:473
uint32_t init_servomotors_USBMSP()
Init servo motors.
Definition: usbMSP430Interface.cpp:253