VRBRAIN: Changed the management of VirtualRobotix's boards.

This commit is contained in:
LukeMike 2014-05-30 22:58:34 +02:00 committed by Emile Castelnuovo
parent 017e4b4c8a
commit 8f552d5758
35 changed files with 408 additions and 1230 deletions

View File

@ -51,11 +51,17 @@ extern const AP_HAL::HAL& hal;
#elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX
#define ARSPD_DEFAULT_PIN AP_AIRSPEED_I2C_PIN
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
#if defined(CONFIG_ARCH_BOARD_VRBRAIN_V4)
#if defined(CONFIG_ARCH_BOARD_VRBRAIN_V40)
#define ARSPD_DEFAULT_PIN 0
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V5)
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V45)
#define ARSPD_DEFAULT_PIN 0
#elif defined(CONFIG_ARCH_BOARD_VRHERO_V1)
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V50)
#define ARSPD_DEFAULT_PIN 0
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V51)
#define ARSPD_DEFAULT_PIN 0
#elif defined(CONFIG_ARCH_BOARD_VRUBRAIN_V51)
#define ARSPD_DEFAULT_PIN 0
#elif defined(CONFIG_ARCH_BOARD_VRHERO_V10)
#define ARSPD_DEFAULT_PIN 0
#endif
#else

View File

@ -51,17 +51,32 @@
# define AP_BATT_CURR_PIN 12
# define AP_BATT_VOLTDIVIDER_DEFAULT 10.1
# define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN && defined(CONFIG_ARCH_BOARD_VRBRAIN_V4)
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN && defined(CONFIG_ARCH_BOARD_VRBRAIN_V40)
# define AP_BATT_VOLT_PIN 100
# define AP_BATT_CURR_PIN -1
# define AP_BATT_VOLTDIVIDER_DEFAULT 1.1
# define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN && defined(CONFIG_ARCH_BOARD_VRBRAIN_V5)
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN && defined(CONFIG_ARCH_BOARD_VRBRAIN_V45)
# define AP_BATT_VOLT_PIN 100
# define AP_BATT_CURR_PIN -1
# define AP_BATT_VOLTDIVIDER_DEFAULT 1.1
# define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN && defined(CONFIG_ARCH_BOARD_VRBRAIN_V50)
# define AP_BATT_VOLT_PIN 100
# define AP_BATT_CURR_PIN 101
# define AP_BATT_VOLTDIVIDER_DEFAULT 1.1
# define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN && defined(CONFIG_ARCH_BOARD_VRHERO_V1)
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN && defined(CONFIG_ARCH_BOARD_VRBRAIN_V51)
# define AP_BATT_VOLT_PIN 100
# define AP_BATT_CURR_PIN 101
# define AP_BATT_VOLTDIVIDER_DEFAULT 1.1
# define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN && defined(CONFIG_ARCH_BOARD_VRUBRAIN_V51)
# define AP_BATT_VOLT_PIN 100
# define AP_BATT_CURR_PIN -1
# define AP_BATT_VOLTDIVIDER_DEFAULT 1.1
# define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN && defined(CONFIG_ARCH_BOARD_VRHERO_V10)
# define AP_BATT_VOLT_PIN 100
# define AP_BATT_CURR_PIN 101
# define AP_BATT_VOLTDIVIDER_DEFAULT 1.1

View File

@ -92,6 +92,9 @@ bool AP_Compass_VRBRAIN::read(void)
}
for (uint8_t i=0; i<_num_instances; i++) {
// avoid division by zero if we haven't received any mag reports
if (_count[i] == 0) continue;
_sum[i] /= _count[i];
_sum[i] *= 1000;
@ -126,9 +129,9 @@ bool AP_Compass_VRBRAIN::read(void)
_count[i] = 0;
}
last_update = _last_timestamp[0];
last_update = _last_timestamp[_get_primary()];
return _healthy[0];
return _healthy[_get_primary()];
}
void AP_Compass_VRBRAIN::accumulate(void)

View File

@ -46,6 +46,8 @@
*/
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4
#define COMPASS_MAX_INSTANCES 2
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
#define COMPASS_MAX_INSTANCES 2
#else
#define COMPASS_MAX_INSTANCES 1
#endif

View File

@ -40,15 +40,25 @@ static const struct {
uint8_t pin;
float scaling;
} pin_scaling[] = {
#ifdef CONFIG_ARCH_BOARD_VRBRAIN_V4
#if defined(CONFIG_ARCH_BOARD_VRBRAIN_V40)
{ 0, 3.3f/4096 },
{ 10, 3.3f/4096 },
{ 11, 3.3f/4096 },
#elif CONFIG_ARCH_BOARD_VRBRAIN_V5
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V45)
{ 0, 3.3f/4096 },
{ 10, 3.3f/4096 },
{ 11, 3.3f/4096 },
#elif CONFIG_ARCH_BOARD_VRHERO_V1
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V50)
{ 0, 3.3f/4096 },
{ 10, 3.3f/4096 },
{ 11, 3.3f/4096 },
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V51)
{ 0, 3.3f/4096 },
{ 10, 3.3f/4096 },
{ 11, 3.3f/4096 },
#elif defined(CONFIG_ARCH_BOARD_VRUBRAIN_V51)
{ 10, 3.3f/4096 },
#elif defined(CONFIG_ARCH_BOARD_VRHERO_V10)
{ 10, 3.3f/4096 },
{ 11, 3.3f/4096 },
{ 14, 3.3f/4096 },

View File

@ -10,14 +10,22 @@
#define VRBRAIN_ANALOG_MAX_CHANNELS 16
#if defined(CONFIG_ARCH_BOARD_VRBRAIN_V4)
// these are virtual pins that read from the ORB
#if defined(CONFIG_ARCH_BOARD_VRBRAIN_V40)
#define VRBRAIN_ANALOG_ORB_BATTERY_VOLTAGE_PIN 10
#define VRBRAIN_ANALOG_ORB_BATTERY_CURRENT_PIN 11
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V5)
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V45)
#define VRBRAIN_ANALOG_ORB_BATTERY_VOLTAGE_PIN 10
#define VRBRAIN_ANALOG_ORB_BATTERY_CURRENT_PIN 11
#elif defined(CONFIG_ARCH_BOARD_VRHERO_V1)
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V50)
#define VRBRAIN_ANALOG_ORB_BATTERY_VOLTAGE_PIN 10
#define VRBRAIN_ANALOG_ORB_BATTERY_CURRENT_PIN 11
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V51)
#define VRBRAIN_ANALOG_ORB_BATTERY_VOLTAGE_PIN 10
#define VRBRAIN_ANALOG_ORB_BATTERY_CURRENT_PIN 11
#elif defined(CONFIG_ARCH_BOARD_VRUBRAIN_V51)
#define VRBRAIN_ANALOG_ORB_BATTERY_VOLTAGE_PIN 10
#define VRBRAIN_ANALOG_ORB_BATTERY_CURRENT_PIN -1
#elif defined(CONFIG_ARCH_BOARD_VRHERO_V10)
#define VRBRAIN_ANALOG_ORB_BATTERY_VOLTAGE_PIN 10
#define VRBRAIN_ANALOG_ORB_BATTERY_CURRENT_PIN 11
#endif

View File

@ -13,7 +13,7 @@
/* VRBRAIN headers */
#include <drivers/drv_led.h>
#include <drivers/drv_tone_alarm.h>
#include <drivers/drv_buzzer.h>
#include <drivers/drv_gpio.h>
#include <arch/board/board.h>
@ -31,7 +31,6 @@ VRBRAINGPIO::VRBRAINGPIO()
void VRBRAINGPIO::init()
{
#if defined(CONFIG_ARCH_BOARD_VRBRAIN_V4) || defined(CONFIG_ARCH_BOARD_VRBRAIN_V5) || defined(CONFIG_ARCH_BOARD_VRHERO_V1)
_led_fd = open(LED_DEVICE_PATH, O_RDWR);
if (_led_fd == -1) {
hal.scheduler->panic("Unable to open " LED_DEVICE_PATH);
@ -42,40 +41,37 @@ void VRBRAINGPIO::init()
if (ioctl(_led_fd, LED_OFF, LED_RED) != 0) {
hal.console->printf("GPIO: Unable to setup GPIO LED RED\n");
}
#endif
_tone_alarm_fd = open("/dev/tone_alarm", O_WRONLY);
if (_tone_alarm_fd == -1) {
hal.scheduler->panic("Unable to open /dev/tone_alarm");
if (ioctl(_led_fd, LED_OFF, LED_GREEN) != 0) {
hal.console->printf("GPIO: Unable to setup GPIO LED GREEN\n");
}
#if !defined(CONFIG_ARCH_BOARD_VRHERO_V10)
if (ioctl(_led_fd, LED_OFF, LED_EXT1) != 0) {
hal.console->printf("GPIO: Unable to setup GPIO LED EXT 1\n");
}
#endif
#if !defined(CONFIG_ARCH_BOARD_VRHERO_V10)
if (ioctl(_led_fd, LED_OFF, LED_EXT2) != 0) {
hal.console->printf("GPIO: Unable to setup GPIO LED EXT 2\n");
}
#endif
#if !defined(CONFIG_ARCH_BOARD_VRHERO_V10) && !defined(CONFIG_ARCH_BOARD_VRUBRAIN_V51)
if (ioctl(_led_fd, LED_OFF, LED_EXT3) != 0) {
hal.console->printf("GPIO: Unable to setup GPIO LED EXT 3\n");
}
#endif
_buzzer_fd = open(BUZZER_DEVICE_PATH, O_RDWR);
if (_buzzer_fd == -1) {
hal.scheduler->panic("Unable to open " BUZZER_DEVICE_PATH);
}
if (ioctl(_buzzer_fd, BUZZER_OFF, BUZZER_EXT) != 0) {
hal.console->printf("GPIO: Unable to setup GPIO BUZZER\n");
}
}
void VRBRAINGPIO::pinMode(uint8_t pin, uint8_t output)
{
switch (pin) {
}
}
@ -85,52 +81,10 @@ int8_t VRBRAINGPIO::analogPinToDigitalPin(uint8_t pin)
}
uint8_t VRBRAINGPIO::read(uint8_t pin) {
uint8_t VRBRAINGPIO::read(uint8_t pin)
{
switch (pin) {
}
return LOW;
}
@ -139,8 +93,23 @@ void VRBRAINGPIO::write(uint8_t pin, uint8_t value)
{
switch (pin) {
#if defined(CONFIG_ARCH_BOARD_VRBRAIN_V4) || defined(CONFIG_ARCH_BOARD_VRBRAIN_V5) || defined(CONFIG_ARCH_BOARD_VRHERO_V1)
case HAL_GPIO_A_LED_PIN: // Arming LED
if (value == LOW) {
ioctl(_led_fd, LED_OFF, LED_GREEN);
} else {
ioctl(_led_fd, LED_ON, LED_GREEN);
}
break;
case HAL_GPIO_B_LED_PIN: // not used yet
if (value == LOW) {
ioctl(_led_fd, LED_OFF, LED_BLUE);
} else {
ioctl(_led_fd, LED_ON, LED_BLUE);
}
break;
case HAL_GPIO_C_LED_PIN: // GPS LED
if (value == LOW) {
ioctl(_led_fd, LED_OFF, LED_RED);
} else {
@ -148,72 +117,86 @@ void VRBRAINGPIO::write(uint8_t pin, uint8_t value)
}
break;
case HAL_GPIO_B_LED_PIN: // not used yet
break;
case HAL_GPIO_C_LED_PIN: // GPS LED
if (value == LOW) {
ioctl(_led_fd, LED_OFF, LED_BLUE);
} else {
ioctl(_led_fd, LED_ON, LED_BLUE);
case EXTERNAL_LED_GPS:
#if !defined(CONFIG_ARCH_BOARD_VRHERO_V10)
if (value == LOW) {
ioctl(_led_fd, LED_OFF, LED_EXT1);
} else {
ioctl(_led_fd, LED_ON, LED_EXT1);
}
break;
#endif
case VRBRAIN_GPIO_PIEZO_PIN: // Piezo beeper
if (value == LOW) { // this is inverted
ioctl(_tone_alarm_fd, TONE_SET_ALARM, 3); // Alarm on !!
//::write(_tone_alarm_fd, &user_tune, sizeof(user_tune));
} else {
ioctl(_tone_alarm_fd, TONE_SET_ALARM, 0); // Alarm off !!
}
break;
case EXTERNAL_LED_ARMED:
#if !defined(CONFIG_ARCH_BOARD_VRHERO_V10)
if (value == LOW) {
ioctl(_led_fd, LED_OFF, LED_EXT2);
} else {
ioctl(_led_fd, LED_ON, LED_EXT2);
}
#endif
break;
case EXTERNAL_LED_MOTOR1:
break;
case EXTERNAL_LED_MOTOR2:
break;
case BUZZER_PIN:
if (value == LOW) {
ioctl(_buzzer_fd, BUZZER_OFF, BUZZER_EXT);
} else {
ioctl(_buzzer_fd, BUZZER_ON, BUZZER_EXT);
}
break;
}
}
void VRBRAINGPIO::toggle(uint8_t pin)
{
write(pin, !read(pin));
switch (pin) {
case HAL_GPIO_A_LED_PIN: // Arming LED
ioctl(_led_fd, LED_TOGGLE, LED_GREEN);
break;
case HAL_GPIO_B_LED_PIN: // not used yet
ioctl(_led_fd, LED_TOGGLE, LED_BLUE);
break;
case HAL_GPIO_C_LED_PIN: // GPS LED
ioctl(_led_fd, LED_TOGGLE, LED_RED);
break;
case EXTERNAL_LED_GPS:
#if !defined(CONFIG_ARCH_BOARD_VRHERO_V10)
ioctl(_led_fd, LED_TOGGLE, LED_EXT1);
#endif
break;
case EXTERNAL_LED_ARMED:
#if !defined(CONFIG_ARCH_BOARD_VRHERO_V10)
ioctl(_led_fd, LED_TOGGLE, LED_EXT2);
#endif
break;
case EXTERNAL_LED_MOTOR1:
break;
case EXTERNAL_LED_MOTOR2:
break;
case BUZZER_PIN:
ioctl(_buzzer_fd, BUZZER_TOGGLE, BUZZER_EXT);
break;
default:
write(pin, !read(pin));
break;
}
}
/* Alternative interface: */

View File

@ -5,27 +5,16 @@
#include <AP_HAL_VRBRAIN.h>
#define VRBRAIN_GPIO_PIEZO_PIN 110
#if CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
# define HAL_GPIO_A_LED_PIN 27
# define HAL_GPIO_A_LED_PIN 25
# define HAL_GPIO_B_LED_PIN 26
# define HAL_GPIO_C_LED_PIN 25
# define HAL_GPIO_C_LED_PIN 27
# define EXTERNAL_LED_GPS 28
# define EXTERNAL_LED_ARMED 29
# define EXTERNAL_LED_MOTOR1 30
# define EXTERNAL_LED_MOTOR2 31
# define BUZZER_PIN 32
# define HAL_GPIO_LED_ON HIGH
# define HAL_GPIO_LED_OFF LOW
#endif
class VRBRAIN::VRBRAINGPIO : public AP_HAL::GPIO {
public:
@ -48,9 +37,7 @@ public:
private:
int _led_fd;
int _tone_alarm_fd;
int _buzzer_fd;
};
class VRBRAIN::VRBRAINDigitalSource : public AP_HAL::DigitalSource {

View File

@ -50,11 +50,49 @@ static VRBRAINGPIO gpioDriver;
#if defined(CONFIG_ARCH_BOARD_VRBRAIN_V40)
#define UARTA_DEFAULT_DEVICE "/dev/ttyACM0"
#define UARTB_DEFAULT_DEVICE "/dev/ttyS1"
#define UARTC_DEFAULT_DEVICE "/dev/ttyS2"
#define UARTD_DEFAULT_DEVICE "/dev/null"
#define UARTE_DEFAULT_DEVICE "/dev/null"
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V45)
#define UARTA_DEFAULT_DEVICE "/dev/ttyACM0"
#define UARTB_DEFAULT_DEVICE "/dev/ttyS1"
#define UARTC_DEFAULT_DEVICE "/dev/ttyS2"
#define UARTD_DEFAULT_DEVICE "/dev/null"
#define UARTE_DEFAULT_DEVICE "/dev/null"
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V50)
#define UARTA_DEFAULT_DEVICE "/dev/ttyACM0"
#define UARTB_DEFAULT_DEVICE "/dev/ttyS1"
#define UARTC_DEFAULT_DEVICE "/dev/ttyS2"
#define UARTD_DEFAULT_DEVICE "/dev/null"
#define UARTE_DEFAULT_DEVICE "/dev/null"
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V51)
#define UARTA_DEFAULT_DEVICE "/dev/ttyACM0"
#define UARTB_DEFAULT_DEVICE "/dev/ttyS0"
#define UARTC_DEFAULT_DEVICE "/dev/ttyS2"
#define UARTD_DEFAULT_DEVICE "/dev/null"
#define UARTE_DEFAULT_DEVICE "/dev/null"
#elif defined(CONFIG_ARCH_BOARD_VRUBRAIN_V51)
#define UARTA_DEFAULT_DEVICE "/dev/ttyACM0"
#define UARTB_DEFAULT_DEVICE "/dev/ttyS0"
#define UARTC_DEFAULT_DEVICE "/dev/ttyS2"
#define UARTD_DEFAULT_DEVICE "/dev/null"
#define UARTE_DEFAULT_DEVICE "/dev/null"
#elif defined(CONFIG_ARCH_BOARD_VRHERO_V10)
#define UARTA_DEFAULT_DEVICE "/dev/ttyACM0"
#define UARTB_DEFAULT_DEVICE "/dev/ttyS1"
#define UARTC_DEFAULT_DEVICE "/dev/ttyS2"
#define UARTD_DEFAULT_DEVICE "/dev/null"
#define UARTE_DEFAULT_DEVICE "/dev/null"
#else
#define UARTA_DEFAULT_DEVICE "/dev/ttyACM0"
#define UARTB_DEFAULT_DEVICE "/dev/ttyS1"
#define UARTC_DEFAULT_DEVICE "/dev/ttyS2"
#define UARTD_DEFAULT_DEVICE "/dev/null"
#define UARTE_DEFAULT_DEVICE "/dev/null"
#endif
// 3 UART drivers, for GPS plus two mavlink-enabled devices

View File

@ -90,7 +90,6 @@ void VRBRAINRCOutput::set_freq(uint32_t chmask, uint16_t freq_hz)
*/
if (freq_hz > 50) {
// we are setting high rates on the given channels
#if defined(CONFIG_ARCH_BOARD_VRBRAIN_V4) || defined(CONFIG_ARCH_BOARD_VRBRAIN_V5) || defined(CONFIG_ARCH_BOARD_VRHERO_V1)
_rate_mask |= chmask & 0xFF;
if (_rate_mask & 0x07) {
_rate_mask |= 0x07;
@ -101,21 +100,8 @@ void VRBRAINRCOutput::set_freq(uint32_t chmask, uint16_t freq_hz)
if (_rate_mask & 0xC0) {
_rate_mask |= 0xC0;
}
#else
_rate_mask |= chmask & 0xFF;
if (_rate_mask & 0x3) {
_rate_mask |= 0x3;
}
if (_rate_mask & 0xc) {
_rate_mask |= 0xc;
}
if (_rate_mask & 0xF0) {
_rate_mask |= 0xF0;
}
#endif
} else {
// we are setting low rates on the given channels
#if defined(CONFIG_ARCH_BOARD_VRBRAIN_V4) || defined(CONFIG_ARCH_BOARD_VRBRAIN_V5) || defined(CONFIG_ARCH_BOARD_VRHERO_V1)
if (chmask & 0x07) {
_rate_mask &= ~0x07;
}
@ -125,17 +111,6 @@ void VRBRAINRCOutput::set_freq(uint32_t chmask, uint16_t freq_hz)
if (chmask & 0xC0) {
_rate_mask &= ~0xC0;
}
#else
if (chmask & 0x3) {
_rate_mask &= ~0x3;
}
if (chmask & 0xc) {
_rate_mask &= ~0xc;
}
if (chmask & 0xf0) {
_rate_mask &= ~0xf0;
}
#endif
}
if (ioctl(_pwm_fd, PWM_SERVO_SET_SELECT_UPDATE_RATE, _rate_mask) != 0) {
@ -183,6 +158,22 @@ void VRBRAINRCOutput::set_safety_pwm(uint32_t chmask, uint16_t period_us)
}
}
void VRBRAINRCOutput::set_failsafe_pwm(uint32_t chmask, uint16_t period_us)
{
struct pwm_output_values pwm_values;
memset(&pwm_values, 0, sizeof(pwm_values));
for (uint8_t i=0; i<_servo_count; i++) {
if ((1UL<<i) & chmask) {
pwm_values.values[i] = period_us;
}
pwm_values.channel_count++;
}
int ret = ioctl(_pwm_fd, PWM_SERVO_SET_FAILSAFE_PWM, (long unsigned int)&pwm_values);
if (ret != OK) {
hal.console->printf("Failed to setup failsafe PWM for 0x%08x to %u\n", (unsigned)chmask, period_us);
}
}
void VRBRAINRCOutput::force_safety_off(void)
{
int ret = ioctl(_pwm_fd, PWM_SERVO_SET_FORCE_SAFETY_OFF, 0);

View File

@ -20,6 +20,7 @@ public:
uint16_t read(uint8_t ch);
void read(uint16_t* period_us, uint8_t len);
void set_safety_pwm(uint32_t chmask, uint16_t period_us);
void set_failsafe_pwm(uint32_t chmask, uint16_t period_us);
void force_safety_off(void);
void _timer_tick(void);

View File

@ -154,8 +154,14 @@ void VRBRAINStorage::_storage_open(void)
if (fd == -1) {
hal.scheduler->panic("Failed to open " MTD_PARAMS_FILE);
}
if (read(fd, _buffer, sizeof(_buffer)) != sizeof(_buffer)) {
hal.scheduler->panic("Failed to read " MTD_PARAMS_FILE);
const uint16_t chunk_size = 128;
for (uint16_t ofs=0; ofs<sizeof(_buffer); ofs += chunk_size) {
ssize_t ret = read(fd, &_buffer[ofs], chunk_size);
if (ret != chunk_size) {
::printf("storage read of %u bytes at %u to %p failed - got %d errno=%d\n",
(unsigned)sizeof(_buffer), (unsigned)ofs, &_buffer[ofs], (int)ret, (int)errno);
hal.scheduler->panic("Failed to read " MTD_PARAMS_FILE);
}
}
close(fd);
_initialised = true;

View File

@ -138,6 +138,9 @@ void VRBRAINUARTDriver::begin(uint32_t b, uint16_t rxS, uint16_t txS)
tcgetattr(_fd, &t);
t.c_cflag |= CRTS_IFLOW;
tcsetattr(_fd, TCSANOW, &t);
// reset _total_written to reset flow control auto check
_total_written = 0;
}
if (_writebuf_size != 0 && _readbuf_size != 0 && _fd != -1) {

View File

@ -106,12 +106,18 @@ bool VRBRAINUtil::get_system_id(char buf[40])
uint8_t serialid[12];
memset(serialid, 0, sizeof(serialid));
get_board_serial(serialid);
#if defined(CONFIG_ARCH_BOARD_VRBRAIN_V4)
const char *board_type = "VRBRAINv4";
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V5)
const char *board_type = "VRBRAINv5";
#elif defined(CONFIG_ARCH_BOARD_VRHERO_V1)
const char *board_type = "VRHEROv1";
#if defined(CONFIG_ARCH_BOARD_VRBRAIN_V40)
const char *board_type = "VRBRAINv40";
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V45)
const char *board_type = "VRBRAINv45";
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V50)
const char *board_type = "VRBRAINv50";
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V51)
const char *board_type = "VRBRAINv51";
#elif defined(CONFIG_ARCH_BOARD_VRUBRAIN_V51)
const char *board_type = "VRUBRAINv51";
#elif defined(CONFIG_ARCH_BOARD_VRHERO_V10)
const char *board_type = "VRHEROv10";
#endif
// this format is chosen to match the human_readable_serial()
// function in auth.c

View File

@ -13,6 +13,8 @@
*/
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 || CONFIG_HAL_BOARD == HAL_BOARD_LINUX || CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL
#define INS_MAX_INSTANCES 2
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
#define INS_MAX_INSTANCES 2
#else
#define INS_MAX_INSTANCES 1
#endif

View File

@ -61,11 +61,11 @@
# define HAL_GPIO_LED_ON LOW
# define HAL_GPIO_LED_OFF HIGH
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
# define HAL_GPIO_A_LED_PIN 27
# define HAL_GPIO_A_LED_PIN 25
# define HAL_GPIO_B_LED_PIN 26
# define HAL_GPIO_C_LED_PIN 25
# define HAL_GPIO_LED_ON LOW
# define HAL_GPIO_LED_OFF HIGH
# define HAL_GPIO_C_LED_PIN 27
# define HAL_GPIO_LED_ON HIGH
# define HAL_GPIO_LED_OFF LOW
#else
#error "Unknown board type in AP_Notify"
#endif

View File

@ -35,7 +35,8 @@ void AP_Notify::init(bool enable_external_leds)
buzzer.init();
#endif
#if CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
tonealarm.init();
externalled.init();
buzzer.init();
#endif
}
@ -53,6 +54,7 @@ void AP_Notify::update(void)
buzzer.update();
#endif
#if CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
tonealarm.update();
externalled.update();
buzzer.update();
#endif
}

View File

@ -26,8 +26,6 @@
#include <ToneAlarm_PX4.h>
#include <ExternalLED.h>
#include <Buzzer.h>
#include <ToshibaLED_VRBRAIN.h>
#include <ToneAlarm_VRBRAIN.h>
class AP_Notify
{
@ -72,8 +70,9 @@ private:
ExternalLED externalled;
Buzzer buzzer;
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
ToshibaLED_VRBRAIN toshibaled;
ToneAlarm_VRBRAIN tonealarm;
ToshibaLED_I2C toshibaled;
ExternalLED externalled;
Buzzer buzzer;
#else
ToshibaLED_I2C toshibaled;
#endif

View File

@ -22,6 +22,8 @@
# define BUZZER_PIN 63 // pin 63 on APM1
#elif CONFIG_HAL_BOARD == HAL_BOARD_APM2
# define BUZZER_PIN 59 // pin 59 on APM2
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
# define BUZZER_PIN 32
#else
# define BUZZER_PIN 0 // pin undefined on other boards
#endif

View File

@ -32,6 +32,11 @@
#define EXTERNAL_LED_ARMED 65 // Armed LED - AN11
#define EXTERNAL_LED_MOTOR1 62 // Motor1 LED - AN8
#define EXTERNAL_LED_MOTOR2 66 // Motor2 LED - AN12
#elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
#define EXTERNAL_LED_GPS 28 // GPS LED - AN10
#define EXTERNAL_LED_ARMED 29 // Armed LED - AN11
#define EXTERNAL_LED_MOTOR1 30 // Motor1 LED - AN8
#define EXTERNAL_LED_MOTOR2 31 // Motor2 LED - AN12
#else
#define EXTERNAL_LED_GPS 0 // pin definitions to allow this lib to build for
#define EXTERNAL_LED_ARMED 0 // for other boards besides APM1, APM2 even though

View File

@ -1,108 +0,0 @@
/*
ToneAlarm VRBRAIN driver
*/
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <AP_HAL.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
#include "ToneAlarm_VRBRAIN.h"
#include "AP_Notify.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <drivers/drv_tone_alarm.h>
#include <stdio.h>
#include <errno.h>
extern const AP_HAL::HAL& hal;
bool ToneAlarm_VRBRAIN::init()
{
// open the tone alarm device
_tonealarm_fd = open(TONEALARM_DEVICE_PATH, 0);
if (_tonealarm_fd == -1) {
hal.console->printf("Unable to open " TONEALARM_DEVICE_PATH);
return false;
}
// set initial boot states. This prevents us issueing a arming
// warning in plane and rover on every boot
flags.armed = AP_Notify::flags.armed;
flags.failsafe_battery = AP_Notify::flags.failsafe_battery;
return true;
}
// play_tune - play one of the pre-defined tunes
bool ToneAlarm_VRBRAIN::play_tune(const uint8_t tune_number)
{
int ret = ioctl(_tonealarm_fd, TONE_SET_ALARM, tune_number);
return (ret == 0);
}
// update - updates led according to timed_updated. Should be called at 50Hz
void ToneAlarm_VRBRAIN::update()
{
// exit immediately if we haven't initialised successfully
if (_tonealarm_fd == -1) {
return;
}
// check if arming status has changed
if (flags.armed != AP_Notify::flags.armed) {
flags.armed = AP_Notify::flags.armed;
if (flags.armed) {
// arming tune
play_tune(TONE_ARMING_WARNING_TUNE);
}else{
// disarming tune
play_tune(TONE_NOTIFY_NEUTRAL_TUNE);
}
}
// check if battery status has changed
if (flags.failsafe_battery != AP_Notify::flags.failsafe_battery) {
flags.failsafe_battery = AP_Notify::flags.failsafe_battery;
if (flags.failsafe_battery) {
// low battery warning tune
play_tune(TONE_BATTERY_WARNING_FAST_TUNE);
}
}
// check gps glitch
if (flags.gps_glitching != AP_Notify::flags.gps_glitching) {
flags.gps_glitching = AP_Notify::flags.gps_glitching;
if (flags.gps_glitching) {
// gps glitch warning tune
play_tune(TONE_GPS_WARNING_TUNE);
}
}
// check gps failsafe
if (flags.failsafe_gps != AP_Notify::flags.failsafe_gps) {
flags.failsafe_gps = AP_Notify::flags.failsafe_gps;
if (flags.failsafe_gps) {
// gps glitch warning tune
play_tune(TONE_GPS_WARNING_TUNE);
}
}
}
#endif // CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN

View File

@ -1,47 +0,0 @@
/*
ToneAlarm VRBRAIN driver
*/
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __TONE_ALARM_VRBRAIN_H__
#define __TONE_ALARM_VRBRAIN_H__
#include "ToneAlarm_VRBRAIN.h"
class ToneAlarm_VRBRAIN
{
public:
/// init - initialised the tone alarm
bool init(void);
/// update - updates led according to timed_updated. Should be called at 50Hz
void update();
private:
/// play_tune - play one of the pre-defined tunes
bool play_tune(const uint8_t tune_number);
int _tonealarm_fd; // file descriptor for the tone alarm
/// tonealarm_type - bitmask of states we track
struct tonealarm_type {
uint8_t armed : 1; // 0 = disarmed, 1 = armed
uint8_t failsafe_battery : 1; // 1 if battery failsafe
uint8_t gps_glitching : 1; // 1 if gps position is not good
uint8_t failsafe_gps : 1; // 1 if gps failsafe
} flags;
};
#endif // __TONE_ALARM_VRBRAIN_H__

View File

@ -1,77 +0,0 @@
/*
ToshibaLED VRBRAIN driver
*/
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <AP_HAL.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN
#include "ToshibaLED_VRBRAIN.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <drivers/drv_rgbled.h>
#include <stdio.h>
#include <errno.h>
extern const AP_HAL::HAL& hal;
bool ToshibaLED_VRBRAIN::hw_init()
{
// open the rgb led device
_rgbled_fd = open(RGBLED_DEVICE_PATH, 0);
if (_rgbled_fd == -1) {
hal.console->printf("Unable to open " RGBLED_DEVICE_PATH);
return false;
}
ioctl(_rgbled_fd, RGBLED_SET_MODE, (unsigned long)RGBLED_MODE_ON);
last.zero();
next.zero();
hal.scheduler->register_io_process(AP_HAL_MEMBERPROC(&ToshibaLED_VRBRAIN::update_timer));
return true;
}
// set_rgb - set color as a combination of red, green and blue values
bool ToshibaLED_VRBRAIN::hw_set_rgb(uint8_t red, uint8_t green, uint8_t blue)
{
hal.scheduler->suspend_timer_procs();
next[0] = red;
next[1] = green;
next[2] = blue;
hal.scheduler->resume_timer_procs();
return true;
}
void ToshibaLED_VRBRAIN::update_timer(void)
{
if (last == next) {
return;
}
rgbled_rgbset_t v;
v.red = next[0];
v.green = next[1];
v.blue = next[2];
ioctl(_rgbled_fd, RGBLED_SET_RGB, (unsigned long)&v);
last = next;
}
#endif // CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN

View File

@ -1,37 +0,0 @@
/*
ToshibaLED VRBRAIN driver
*/
/*
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __TOSHIBA_LED_VRBRAIN_H__
#define __TOSHIBA_LED_VRBRAIN_H__
#include "ToshibaLED.h"
#include "AP_Math.h"
#include "vectorN.h"
class ToshibaLED_VRBRAIN : public ToshibaLED
{
public:
bool hw_init(void);
bool hw_set_rgb(uint8_t r, uint8_t g, uint8_t b);
private:
int _rgbled_fd;
void update_timer(void);
VectorN<uint8_t,3> last, next;
};
#endif // __TOSHIBA_LED_VRBRAIN_H__

View File

@ -45,11 +45,17 @@ DataFlash_File::DataFlash_File(const char *log_directory) :
#if defined(CONFIG_ARCH_BOARD_PX4FMU_V1)
// V1 gets IO errors with larger than 512 byte writes
_writebuf_chunk(512),
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V4)
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V40)
_writebuf_chunk(512),
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V5)
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V45)
_writebuf_chunk(512),
#elif defined(CONFIG_ARCH_BOARD_VRHERO_V1)
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V50)
_writebuf_chunk(512),
#elif defined(CONFIG_ARCH_BOARD_VRBRAIN_V51)
_writebuf_chunk(512),
#elif defined(CONFIG_ARCH_BOARD_VRUBRAIN_V51)
_writebuf_chunk(512),
#elif defined(CONFIG_ARCH_BOARD_VRHERO_V10)
_writebuf_chunk(512),
#else
_writebuf_chunk(4096),

View File

@ -1,148 +0,0 @@
#!nsh
# APM startup script for NuttX on VRBRAIN
# To disable APM startup add a /fs/microsd/APM/nostart file
# check for an old file called APM, caused by
# a bug in an earlier firmware release
if [ -f /fs/microsd/APM ]
then
echo "[APM] APM file found - renaming"
mv /fs/microsd/APM /fs/microsd/APM.old
fi
if [ -f /fs/microsd/APM/nostart ]
then
echo "[APM] APM/nostart found - skipping APM startup"
sh /etc/init.d/rc.error
fi
# mount binfs so we can find the built-in apps
if [ -f /bin/reboot ]
then
echo "[APM] binfs already mounted"
else
echo "[APM] Mounting binfs"
if mount -t binfs /dev/null /bin
then
echo "[APM] binfs mounted OK"
else
sh /etc/init.d/rc.error
fi
fi
if rm /fs/microsd/APM/boot.log
then
echo "[APM] Removed old boot.log"
fi
set logfile /fs/microsd/APM/BOOT.LOG
if [ ! -f /bin/ArduPilot ]
then
echo "[APM] /bin/ArduPilot not found"
sh /etc/init.d/rc.error
fi
if mkdir /fs/microsd/APM > /dev/null
then
echo "[APM] Created APM directory"
fi
echo "[APM] Starting UORB"
if uorb start
then
echo "[APM] UORB started OK"
else
sh /etc/init.d/rc.error
fi
echo "[APM] Starting ADC"
if adc start
then
echo "[APM] ADC started OK"
else
sh /etc/init.d/rc.error
fi
echo "[APM] Starting APM sensors"
if ms5611 start
then
echo "[APM] MS5611 started OK"
else
echo "[APM] MS5611 start failed"
sh /etc/init.d/rc.error
fi
if hmc5883 start
then
echo "[APM] HMC5883 started OK"
else
echo "[APM] HMC5883 start failed"
sh /etc/init.d/rc.error
fi
if mpu6000 start
then
echo "[APM] MPU6000 started OK"
else
echo "[APM] MPU6000 start failed"
sh /etc/init.d/rc.error
fi
echo "[APM] Starting MTD driver"
if mtd start /fs/mtd
then
echo "[APM] MTD driver started OK"
else
echo "[APM] MTD driver start failed"
sh /etc/init.d/rc.error
fi
echo "[APM] MTD driver read test"
if mtd readtest /fs/mtd
then
echo "[APM] MTD driver readtest OK"
else
echo "[APM] MTD driver failed to read"
sh /etc/init.d/rc.error
fi
echo "[APM] Starting VROUTPUT driver"
vroutput mode_pwm
#if vroutput mode_pwm
#then
# echo "[APM] VROUTPUT driver started OK"
#else
# echo "[APM] VROUTPUT driver start failed"
# sh /etc/init.d/rc.error
#fi
echo "[APM] Starting VRINPUT driver"
vrinput start
#if vrinput start
#then
# echo "[APM] VRINPUT driver started OK"
#else
# echo "[APM] VRINPUT driver start failed"
# sh /etc/init.d/rc.error
#fi
set sketch NONE
set deviceA /dev/ttyACM0
set deviceC /dev/ttyS2
echo "[APM] Starting ArduPilot" $deviceA $deviceC
if ArduPilot -d $deviceA -d2 $deviceC start
then
echo "[APM] ArduPilot started OK"
else
echo "[APM] ArduPilot start failed"
sh /etc/init.d/rc.error
fi
echo "[APM] Exiting from nsh shell"
exit
echo "[APM] Script finished"

View File

@ -1,121 +0,0 @@
#!nsh
# APM startup script for NuttX on VRBRAIN
# mount binfs so we can find the built-in apps
if [ -f /bin/reboot ]
then
echo "[APMNS] binfs already mounted"
else
echo "[APMNS] Mounting binfs"
if mount -t binfs /dev/null /bin
then
echo "[APMNS] binfs mounted OK"
else
sh /etc/init.d/rc.error
fi
fi
if [ ! -f /bin/ArduPilot ]
then
echo "[APMNS] /bin/ArduPilot not found"
sh /etc/init.d/rc.error
fi
echo "[APMNS] Starting UORB"
if uorb start
then
echo "[APMNS] UORB started OK"
else
sh /etc/init.d/rc.error
fi
echo "[APMNS] Starting ADC"
if adc start
then
echo "[APMNS] ADC started OK"
else
sh /etc/init.d/rc.error
fi
echo "[APMNS] Starting APM sensors"
if ms5611 start
then
echo "[APMNS] MS5611 started OK"
else
echo "[APMNS] MS5611 start failed"
sh /etc/init.d/rc.error
fi
if hmc5883 start
then
echo "[APMNS] HMC5883 started OK"
else
echo "[APMNS] HMC5883 start failed"
sh /etc/init.d/rc.error
fi
if mpu6000 start
then
echo "[APMNS] MPU6000 started OK"
else
echo "[APMNS] MPU6000 start failed"
sh /etc/init.d/rc.error
fi
echo "[APMNS] Starting MTD driver"
if mtd start /fs/mtd
then
echo "[APMNS] MTD driver started OK"
else
echo "[APMNS] MTD driver start failed"
sh /etc/init.d/rc.error
fi
echo "[APMNS] MTD driver read test"
if mtd readtest /fs/mtd
then
echo "[APMNS] MTD driver readtest OK"
else
echo "[APMNS] MTD driver failed to read"
sh /etc/init.d/rc.error
fi
echo "[APMNS] Starting VROUTPUT driver"
vroutput mode_pwm
#if vroutput mode_pwm
#then
# echo "[APMNS] VROUTPUT driver started OK"
#else
# echo "[APMNS] VROUTPUT driver start failed"
# sh /etc/init.d/rc.error
#fi
echo "[APMNS] Starting VRINPUT driver"
vrinput start
#if vrinput start
#then
# echo "[APMNS] VRINPUT driver started OK"
#else
# echo "[APMNS] VRINPUT driver start failed"
# sh /etc/init.d/rc.error
#fi
set sketch NONE
set deviceA /dev/ttyACM0
set deviceC /dev/ttyS2
echo "[APMNS] Starting ArduPilot" $deviceA $deviceC
if ArduPilot -d $deviceA -d2 $deviceC start
then
echo "[APMNS] ArduPilot started OK"
else
echo "[APMNS] ArduPilot start failed"
sh /etc/init.d/rc.error
fi
echo "[APMNS] Exiting from nsh shell"
exit
echo "[APMNS] Script finished"

View File

@ -1,14 +0,0 @@
echo "Error in startup"
tone_alarm MNCC
nshterm /dev/ttyACM0 &
sleep 1
nshterm /dev/ttyS0 &
sleep 1
exit

View File

@ -1,97 +0,0 @@
#!nsh
#
# VRBRAIN startup script.
#
# This script is responsible for:
#
# - mounting the microSD card (if present)
# - running the user startup script from the microSD card (if present)
# - detecting the configuration of the system and picking a suitable
# startup script to continue with
#
# Note: DO NOT add configuration-specific commands to this script;
# add them to the per-configuration scripts instead.
#
#
# Default to auto-start mode. An init script on the microSD card
# can change this to prevent automatic startup of the flight script.
#
set MODE autostart
set USB autoconnect
#
# Try to mount the microSD card.
#
echo "[init] looking for microSD..."
if mount -t vfat /dev/mmcsd0 /fs/microsd
then
echo "[init] card mounted at /fs/microsd"
set HAVE_MICROSD 1
# Start playing the startup tune
tone_alarm start
else
echo "[init] no microSD card found"
set HAVE_MICROSD 0
# Play SOS
tone_alarm 2
fi
#
# Look for an init script on the microSD card.
#
# To prevent automatic startup in the current flight mode,
# the script should set MODE to some other value.
#
if [ -f /fs/microsd/etc/rc ]
then
echo "[init] reading /fs/microsd/etc/rc"
sh /fs/microsd/etc/rc
fi
# Also consider rc.txt files
if [ -f /fs/microsd/etc/rc.txt ]
then
echo "[init] reading /fs/microsd/etc/rc.txt"
sh /fs/microsd/etc/rc.txt
fi
#
# Check for USB host
#
if [ $USB != autoconnect ]
then
echo "[init] not connecting USB"
else
if sercon
then
echo "[init] USB interface connected"
else
echo "[init] No USB connected"
fi
fi
if [ $HAVE_MICROSD == 1 ]
then
if [ ! -f /fs/microsd/APM/nostart ]
then
if [ -f /etc/init.d/rc.APM ]
then
echo "[init] Running rc.APM"
# if APM startup is successful then nsh will exit
sh /etc/init.d/rc.APM
else
nshterm /dev/ttyACM0 &
fi
else
nshterm /dev/ttyACM0 &
fi
else
if [ -f /etc/init.d/rc.APMNS ]
then
echo "[init] Running rc.APM without SD"
# if APM startup is successful then nsh will exit
sh /etc/init.d/rc.APMNS
else
nshterm /dev/ttyACM0 &
fi
fi

View File

@ -1,165 +0,0 @@
#
# Makefile for the vrbrain-v4_APM configuration
#
#
# Use the configuration's ROMFS.
#
ROMFS_ROOT = $(SKETCHBOOK)/mk/VRBRAIN/ROMFS
MODULES += $(APM_MODULE_DIR)
#
# Board support modules
#
MODULES += drivers/device
MODULES += drivers/stm32
MODULES += drivers/stm32/adc
MODULES += drivers/stm32/tone_alarm
MODULES += drivers/led
MODULES += drivers/boards/vrbrain-v4
MODULES += drivers/vrbrain/vroutput
MODULES += drivers/vrbrain/vrinput/controls
MODULES += drivers/vrbrain/vrinput
MODULES += drivers/mpu6000
MODULES += drivers/hmc5883
MODULES += drivers/ms5611
#
# System commands
#
MODULES += systemcmds/mtd
MODULES += systemcmds/top
MODULES += systemcmds/tests
MODULES += systemcmds/nshterm
#
# General system control
#
#
# Estimation modules (EKF/ SO3 / other filters)
#
#
# Vehicle Control
#
#
# Logging
#
#
# Unit tests
#
#
# Library modules
#
MODULES += modules/systemlib
MODULES += modules/uORB
#
# Libraries
#
MODULES += lib/mathlib/math/filter
#
# Transitional support - add commands from the NuttX export archive.
#
# In general, these should move to modules over time.
#
# Each entry here is <command>.<priority>.<stacksize>.<entrypoint> but we use a helper macro
# to make the table a bit more readable.
#
define _B
$(strip $1).$(or $(strip $2),SCHED_PRIORITY_DEFAULT).$(or $(strip $3),CONFIG_PTHREAD_STACK_DEFAULT).$(strip $4)
endef
# command priority stack entrypoint
BUILTIN_COMMANDS := \
$(call _B, sercon, , 2048, sercon_main ) \
$(call _B, serdis, , 2048, serdis_main ) \
$(call _B, msconn, , 2048, msconn_main ) \
$(call _B, msdis, , 2048, msdis_main ) \
$(call _B, sysinfo, , 2048, sysinfo_main )

View File

@ -1,165 +0,0 @@
#
# Makefile for the vrbrain-v5_APM configuration
#
#
# Use the configuration's ROMFS.
#
ROMFS_ROOT = $(SKETCHBOOK)/mk/VRBRAIN/ROMFS
MODULES += $(APM_MODULE_DIR)
#
# Board support modules
#
MODULES += drivers/device
MODULES += drivers/stm32
MODULES += drivers/stm32/adc
MODULES += drivers/stm32/tone_alarm
MODULES += drivers/led
MODULES += drivers/boards/vrbrain-v5
MODULES += drivers/vrbrain/vroutput
MODULES += drivers/vrbrain/vrinput/controls
MODULES += drivers/vrbrain/vrinput
MODULES += drivers/mpu6000
MODULES += drivers/hmc5883
MODULES += drivers/ms5611
#
# System commands
#
MODULES += systemcmds/mtd
MODULES += systemcmds/top
MODULES += systemcmds/tests
MODULES += systemcmds/nshterm
#
# General system control
#
#
# Estimation modules (EKF/ SO3 / other filters)
#
#
# Vehicle Control
#
#
# Logging
#
#
# Unit tests
#
#
# Library modules
#
MODULES += modules/systemlib
MODULES += modules/uORB
#
# Libraries
#
MODULES += lib/mathlib/math/filter
#
# Transitional support - add commands from the NuttX export archive.
#
# In general, these should move to modules over time.
#
# Each entry here is <command>.<priority>.<stacksize>.<entrypoint> but we use a helper macro
# to make the table a bit more readable.
#
define _B
$(strip $1).$(or $(strip $2),SCHED_PRIORITY_DEFAULT).$(or $(strip $3),CONFIG_PTHREAD_STACK_DEFAULT).$(strip $4)
endef
# command priority stack entrypoint
BUILTIN_COMMANDS := \
$(call _B, sercon, , 2048, sercon_main ) \
$(call _B, serdis, , 2048, serdis_main ) \
$(call _B, msconn, , 2048, msconn_main ) \
$(call _B, msdis, , 2048, msdis_main ) \
$(call _B, sysinfo, , 2048, sysinfo_main )

View File

@ -26,9 +26,9 @@ endif
@echo NUTTX_SRC=../PX4NuttX/nuttx >> $(SKETCHBOOK)/config.mk
###################### VRBRAIN ##################################
@echo \# VRBRAIN Firmware tree: >> $(SKETCHBOOK)/config.mk
@echo VRBRAIN_ROOT=../VRBRAINFirmware >> $(SKETCHBOOK)/config.mk
@echo VRBRAIN_ROOT=../VRNuttX >> $(SKETCHBOOK)/config.mk
@echo >> $(SKETCHBOOK)/config.mk
@echo \# VRBRAIN NuttX tree: >> $(SKETCHBOOK)/config.mk
@echo VRBRAIN_NUTTX_SRC=../VRBRAINFirmware/NuttX/nuttx >> $(SKETCHBOOK)/config.mk
@echo VRBRAIN_NUTTX_SRC=../VRNuttX/NuttX/nuttx >> $(SKETCHBOOK)/config.mk
@echo >> $(SKETCHBOOK)/config.mk

View File

@ -80,6 +80,18 @@ ifneq ($(findstring vrbrain, $(MAKECMDGOALS)),)
BUILDROOT := $(SKETCHBOOK)/Build.$(SKETCH)
endif
ifneq ($(findstring vrubrain, $(MAKECMDGOALS)),)
# when building vrbrain we need all sources to be inside the sketchbook directory
# as the NuttX build system relies on it
BUILDROOT := $(SKETCHBOOK)/Build.$(SKETCH)
endif
ifneq ($(findstring vrhero, $(MAKECMDGOALS)),)
# when building vrbrain we need all sources to be inside the sketchbook directory
# as the NuttX build system relies on it
BUILDROOT := $(SKETCHBOOK)/Build.$(SKETCH)
endif
ifeq ($(BUILDROOT),)
BUILDROOT := $(abspath $(TMPDIR)/$(SKETCH).build)
endif
@ -130,6 +142,14 @@ ifneq ($(findstring vrbrain, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_VRBRAIN
endif
ifneq ($(findstring vrubrain, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_VRBRAIN
endif
ifneq ($(findstring vrhero, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_VRBRAIN
endif
ifneq ($(findstring apm1, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_APM1
endif

View File

@ -40,7 +40,7 @@ empty: all
# cope with copter and hil targets
FRAMES = quad tri hexa y6 octa octa-quad heli single
BOARDS = apm1 apm2 apm2beta apm1-1280 px4 px4-v1 px4-v2 sitl flymaple linux vrbrain vrbrain-v4 vrbrainv-5 vrhero-v1
BOARDS = apm1 apm2 apm2beta apm1-1280 px4 px4-v1 px4-v2 sitl flymaple linux vrbrain vrbrain-v40 vrbrain-v45 vrbrainv-50 vrbrain-v51 vrubrain-v51 vrhero-v10
define frame_template
$(1)-$(2) : EXTRAFLAGS += "-DFRAME_CONFIG=$(shell echo $(2) | tr a-z A-Z | sed s/-/_/g)_FRAME "

View File

@ -32,10 +32,13 @@ endif
# we have different config files for vrbrain_v4, vrbrain_v5 and vrhero_v1
VRBRAIN_VB4_CONFIG_FILE=$(MK_DIR)/VRBRAIN/config_vrbrain-v4_APM.mk
VRBRAIN_VB5_CONFIG_FILE=$(MK_DIR)/VRBRAIN/config_vrbrain-v5_APM.mk
VRBRAIN_VH1_CONFIG_FILE=$(MK_DIR)/VRBRAIN/config_vrhero-v1_APM.mk
# we have different config files for vrbrain_v40, vrbrain_v45, vrbrain_v50, vrbrain_v51, vrubrain_v51 and vrhero_v10
VRBRAIN_VB40_CONFIG_FILE=$(MK_DIR)/VRBRAIN/config_vrbrain-v40_APM.mk
VRBRAIN_VB45_CONFIG_FILE=$(MK_DIR)/VRBRAIN/config_vrbrain-v45_APM.mk
VRBRAIN_VB50_CONFIG_FILE=$(MK_DIR)/VRBRAIN/config_vrbrain-v50_APM.mk
VRBRAIN_VB51_CONFIG_FILE=$(MK_DIR)/VRBRAIN/config_vrbrain-v51_APM.mk
VRBRAIN_VU51_CONFIG_FILE=$(MK_DIR)/VRBRAIN/config_vrubrain-v51_APM.mk
VRBRAIN_VH10_CONFIG_FILE=$(MK_DIR)/VRBRAIN/config_vrhero-v10_APM.mk
SKETCHFLAGS=$(SKETCHLIBINCLUDES) -I$(PWD) -DARDUPILOT_BUILD -DCONFIG_HAL_BOARD=HAL_BOARD_VRBRAIN -DSKETCHNAME="\\\"$(SKETCH)\\\"" -DSKETCH_MAIN=ArduPilot_main -DAPM_BUILD_DIRECTORY=APM_BUILD_$(SKETCH)
@ -54,36 +57,74 @@ module_mk:
$(v) cmp $(SKETCHBOOK)/module.mk $(SKETCHBOOK)/module.mk.new 2>/dev/null || mv $(SKETCHBOOK)/module.mk.new $(SKETCHBOOK)/module.mk
$(v) rm -f $(SKETCHBOOK)/module.mk.new
vrbrain-v4: showflags $(VRBRAIN_ROOT)/Archives/vrbrain-v4.export $(SKETCHCPP) module_mk
vrbrain-v40: showflags $(VRBRAIN_ROOT)/Archives/vrbrain-v40.export $(SKETCHCPP) module_mk
$(RULEHDR)
$(v) rm -f $(VRBRAIN_ROOT)/makefiles/$(VRBRAIN_VB4_CONFIG_FILE)
$(v) cp $(SRCROOT)/$(VRBRAIN_VB4_CONFIG_FILE) $(VRBRAIN_ROOT)/makefiles/
$(v) $(VRBRAIN_MAKE) vrbrain-v4_APM
$(v) /bin/rm -f $(SKETCH)-vrbrain-v4.vrbrain
$(v) cp $(VRBRAIN_ROOT)/Images/vrbrain-v4_APM.vrbrain $(SKETCH)-vrbrain-v4.vbrain
$(v) echo "VRBRAIN $(SKETCH) Firmware is in $(SKETCH)-vrbrain-v4.vbrain"
$(v) rm -f $(VRBRAIN_ROOT)/makefiles/$(VRBRAIN_VB40_CONFIG_FILE)
$(v) cp $(SRCROOT)/$(VRBRAIN_VB40_CONFIG_FILE) $(VRBRAIN_ROOT)/makefiles/
$(v) $(VRBRAIN_MAKE) vrbrain-v40_APM
$(v) /bin/rm -f $(SKETCH)-vrbrain-v40.vrx
$(v) cp $(VRBRAIN_ROOT)/Images/vrbrain-v40_APM.vrx $(SKETCH)-vrbrain-v40.vrx
$(v) cp $(VRBRAIN_ROOT)/Images/vrbrain-v40_APM.hex $(SKETCH)-vrbrain-v40.hex
$(v) cp $(VRBRAIN_ROOT)/Images/vrbrain-v40_APM.bin $(SKETCH)-vrbrain-v40.bin
$(v) echo "VRBRAIN $(SKETCH) Firmware is in $(SKETCH)-vrbrain-v40.vrx"
vrbrain-v5: showflags $(VRBRAIN_ROOT)/Archives/vrbrain-v5.export $(SKETCHCPP) module_mk
vrbrain-v45: showflags $(VRBRAIN_ROOT)/Archives/vrbrain-v45.export $(SKETCHCPP) module_mk
$(RULEHDR)
$(v) rm -f $(VRBRAIN_ROOT)/makefiles/$(VRBRAIN_VB5_CONFIG_FILE)
$(v) cp $(SRCROOT)/$(VRBRAIN_VB5_CONFIG_FILE) $(VRBRAIN_ROOT)/makefiles/
$(v) $(VRBRAIN_MAKE) vrbrain-v5_APM
$(v) /bin/rm -f $(SKETCH)-vrbrain-v5.vrbrain
$(v) cp $(VRBRAIN_ROOT)/Images/vrbrain-v5_APM.vrbrain $(SKETCH)-vrbrain-v5.vbrain
$(v) echo "VRBRAIN $(SKETCH) Firmware is in $(SKETCH)-vrbrain-v5.vbrain"
$(v) rm -f $(VRBRAIN_ROOT)/makefiles/$(VRBRAIN_VB45_CONFIG_FILE)
$(v) cp $(SRCROOT)/$(VRBRAIN_VB45_CONFIG_FILE) $(VRBRAIN_ROOT)/makefiles/
$(v) $(VRBRAIN_MAKE) vrbrain-v45_APM
$(v) /bin/rm -f $(SKETCH)-vrbrain-v45.vrx
$(v) cp $(VRBRAIN_ROOT)/Images/vrbrain-v45_APM.vrx $(SKETCH)-vrbrain-v45.vrx
$(v) cp $(VRBRAIN_ROOT)/Images/vrbrain-v45_APM.hex $(SKETCH)-vrbrain-v45.hex
$(v) cp $(VRBRAIN_ROOT)/Images/vrbrain-v45_APM.bin $(SKETCH)-vrbrain-v45.bin
$(v) echo "VRBRAIN $(SKETCH) Firmware is in $(SKETCH)-vrbrain-v45.vrx"
vrhero-v1: showflags $(VRBRAIN_ROOT)/Archives/vrhero-v1.export $(SKETCHCPP) module_mk
vrbrain-v50: showflags $(VRBRAIN_ROOT)/Archives/vrbrain-v50.export $(SKETCHCPP) module_mk
$(RULEHDR)
$(v) rm -f $(VRBRAIN_ROOT)/makefiles/$(VRBRAIN_VH1_CONFIG_FILE)
$(v) cp $(SRCROOT)/$(VRBRAIN_VH1_CONFIG_FILE) $(VRBRAIN_ROOT)/makefiles/
$(v) $(VRBRAIN_MAKE) vrhero-v1_APM
$(v) /bin/rm -f $(SKETCH)-vrhero-v1.vrbrain
$(v) cp $(VRBRAIN_ROOT)/Images/vrhero-v1_APM.vrbrain $(SKETCH)-vrhero-v1.vbrain
$(v) echo "VRBRAIN $(SKETCH) Firmware is in $(SKETCH)-vrhero-v1.vbrain"
$(v) rm -f $(VRBRAIN_ROOT)/makefiles/$(VRBRAIN_VB50_CONFIG_FILE)
$(v) cp $(SRCROOT)/$(VRBRAIN_VB50_CONFIG_FILE) $(VRBRAIN_ROOT)/makefiles/
$(v) $(VRBRAIN_MAKE) vrbrain-v50_APM
$(v) /bin/rm -f $(SKETCH)-vrbrain-v50.vrx
$(v) cp $(VRBRAIN_ROOT)/Images/vrbrain-v50_APM.vrx $(SKETCH)-vrbrain-v50.vrx
$(v) cp $(VRBRAIN_ROOT)/Images/vrbrain-v50_APM.hex $(SKETCH)-vrbrain-v50.hex
$(v) cp $(VRBRAIN_ROOT)/Images/vrbrain-v50_APM.bin $(SKETCH)-vrbrain-v50.bin
$(v) echo "VRBRAIN $(SKETCH) Firmware is in $(SKETCH)-vrbrain-v50.vrx"
#vrbrain: vrbrain-v4 vrbrain-v5 vrhero-v1
vrbrain: vrbrain-v4 vrbrain-v5
#vrbrain: vrbrain-v4
vrbrain-v51: showflags $(VRBRAIN_ROOT)/Archives/vrbrain-v51.export $(SKETCHCPP) module_mk
$(RULEHDR)
$(v) rm -f $(VRBRAIN_ROOT)/makefiles/$(VRBRAIN_VB51_CONFIG_FILE)
$(v) cp $(SRCROOT)/$(VRBRAIN_VB51_CONFIG_FILE) $(VRBRAIN_ROOT)/makefiles/
$(v) $(VRBRAIN_MAKE) vrbrain-v51_APM
$(v) /bin/rm -f $(SKETCH)-vrbrain-v51.vrx
$(v) cp $(VRBRAIN_ROOT)/Images/vrbrain-v51_APM.vrx $(SKETCH)-vrbrain-v51.vrx
$(v) cp $(VRBRAIN_ROOT)/Images/vrbrain-v51_APM.hex $(SKETCH)-vrbrain-v51.hex
$(v) cp $(VRBRAIN_ROOT)/Images/vrbrain-v51_APM.bin $(SKETCH)-vrbrain-v51.bin
$(v) echo "VRBRAIN $(SKETCH) Firmware is in $(SKETCH)-vrbrain-v51.vrx"
vrubrain-v51: showflags $(VRBRAIN_ROOT)/Archives/vrubrain-v51.export $(SKETCHCPP) module_mk
$(RULEHDR)
$(v) rm -f $(VRBRAIN_ROOT)/makefiles/$(VRBRAIN_VU51_CONFIG_FILE)
$(v) cp $(SRCROOT)/$(VRBRAIN_VU51_CONFIG_FILE) $(VRBRAIN_ROOT)/makefiles/
$(v) $(VRBRAIN_MAKE) vrubrain-v51_APM
$(v) /bin/rm -f $(SKETCH)-vrubrain-v51.vrx
$(v) cp $(VRBRAIN_ROOT)/Images/vrubrain-v51_APM.vrx $(SKETCH)-vrubrain-v51.vrx
$(v) cp $(VRBRAIN_ROOT)/Images/vrubrain-v51_APM.hex $(SKETCH)-vrubrain-v51.hex
$(v) cp $(VRBRAIN_ROOT)/Images/vrubrain-v51_APM.bin $(SKETCH)-vrubrain-v51.bin
$(v) echo "MICRO VRBRAIN $(SKETCH) Firmware is in $(SKETCH)-vrubrain-v51.vrx"
vrhero-v10: showflags $(VRBRAIN_ROOT)/Archives/vrhero-v10.export $(SKETCHCPP) module_mk
$(RULEHDR)
$(v) rm -f $(VRBRAIN_ROOT)/makefiles/$(VRBRAIN_VH10_CONFIG_FILE)
$(v) cp $(SRCROOT)/$(VRBRAIN_VH10_CONFIG_FILE) $(VRBRAIN_ROOT)/makefiles/
$(v) $(VRBRAIN_MAKE) vrhero-v10_APM
$(v) /bin/rm -f $(SKETCH)-vrhero-v10.vrx
$(v) cp $(VRBRAIN_ROOT)/Images/vrhero-v10_APM.vrx $(SKETCH)-vrhero-v10.vrx
$(v) cp $(VRBRAIN_ROOT)/Images/vrhero-v10_APM.hex $(SKETCH)-vrhero-v10.hex
$(v) cp $(VRBRAIN_ROOT)/Images/vrhero-v10_APM.bin $(SKETCH)-vrhero-v10.bin
$(v) echo "VRBRAIN $(SKETCH) Firmware is in $(SKETCH)-vrhero-v10.vrx"
#vrbrain: vrbrain-v40 vrbrain-v45 vrbrain-v50 vrbrain-v51 vrubrain-v51 vrhero-v10
vrbrain: vrbrain-v45 vrubrain-v51
vrbrain-clean: clean vrbrain-archives-clean
$(v) /bin/rm -rf $(VRBRAIN_ROOT)/makefiles/build $(VRBRAIN_ROOT)/Build
@ -91,30 +132,51 @@ vrbrain-clean: clean vrbrain-archives-clean
vrbrain-cleandep: clean
$(v) find $(VRBRAIN_ROOT)/Build -type f -name '*.d' | xargs rm -f
vrbrain-v4-upload: vrbrain-v4
vrbrain-v40-upload: vrbrain-v40
$(RULEHDR)
$(v) $(VRBRAIN_MAKE) vrbrain-v4_APM upload
$(v) $(VRBRAIN_MAKE) vrbrain-v40_APM upload
vrbrain-v5-upload: vrbrain-v5
vrbrain-v45-upload: vrbrain-v45
$(RULEHDR)
$(v) $(VRBRAIN_MAKE) vrbrain-v5_APM upload
$(v) $(VRBRAIN_MAKE) vrbrain-v45_APM upload
vrhero-v1-upload: vrhero-v1
vrbrain-v50-upload: vrbrain-v50
$(RULEHDR)
$(v) $(VRBRAIN_MAKE) vrhero-v1_APM upload
$(v) $(VRBRAIN_MAKE) vrbrain-v50_APM upload
vrbrain-upload: vrbrain-v4-upload
vrbrain-v51-upload: vrbrain-v51
$(RULEHDR)
$(v) $(VRBRAIN_MAKE) vrbrain-v51_APM upload
vrubrain-v51-upload: vrubrain-v51
$(RULEHDR)
$(v) $(VRBRAIN_MAKE) vrubrain-v51_APM upload
vrhero-v10-upload: vrhero-v10
$(RULEHDR)
$(v) $(VRBRAIN_MAKE) vrhero-v10_APM upload
vrbrain-upload: vrbrain-v40-upload
vrbrain-archives-clean:
$(v) /bin/rm -rf $(VRBRAIN_ROOT)/Archives
$(VRBRAIN_ROOT)/Archives/vrbrain-v4.export:
$(VRBRAIN_ROOT)/Archives/vrbrain-v40.export:
$(v) $(VRBRAIN_MAKE_ARCHIVES)
$(VRBRAIN_ROOT)/Archives/vrbrain-v5.export:
$(VRBRAIN_ROOT)/Archives/vrbrain-v45.export:
$(v) $(VRBRAIN_MAKE_ARCHIVES)
$(VRBRAIN_ROOT)/Archives/vrhero-v1.export:
$(VRBRAIN_ROOT)/Archives/vrbrain-v50.export:
$(v) $(VRBRAIN_MAKE_ARCHIVES)
$(VRBRAIN_ROOT)/Archives/vrbrain-v51.export:
$(v) $(VRBRAIN_MAKE_ARCHIVES)
$(VRBRAIN_ROOT)/Archives/vrubrain-v51.export:
$(v) $(VRBRAIN_MAKE_ARCHIVES)
$(VRBRAIN_ROOT)/Archives/vrhero-v10.export:
$(v) $(VRBRAIN_MAKE_ARCHIVES)
vrbrain-archives: