Skip to content

Commit

Permalink
Merge branch 'gpio'
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-kirienko committed Feb 21, 2019
2 parents d121430 + 0ee9ade commit 1a8187a
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 11 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ If you're not running Linux or OSX natively, you can use

### Change Log

#### v1.2

* Added a new CLI command: `gpio`. This command allows one to control the SMD GPIO pads via USB/UART.
* [Fixed handling of zero-length USB transactions](http://www.chibios.com/forum/viewtopic.php?f=25&t=4568&p=32429).
* Fixed naming of software version fields in the bootloader: `fw_` --> `sw_`.

#### v1.1

* CAN terminator is turned ON by default.
Expand Down
2 changes: 1 addition & 1 deletion bootloader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ PROJECT = com.zubax.babel

HW_VERSION = 1
BL_VERSION_MAJOR = 1
BL_VERSION_MINOR = 0
BL_VERSION_MINOR = 1

APPLICATION_OFFSET = 32768

Expand Down
4 changes: 2 additions & 2 deletions bootloader/src/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ class ZubaxIDCommand : public os::shell::ICommandHandler
if (appinfo.second)
{
const auto& inf = appinfo.first;
ios.print("fw_version : '%u.%u'\n", inf.major_version, inf.minor_version);
ios.print("fw_vcs_commit: %u\n", inf.vcs_commit);
ios.print("sw_version : '%u.%u'\n", inf.major_version, inf.minor_version);
ios.print("sw_vcs_commit: %u\n", inf.vcs_commit);
}
}
} static cmd_zubax_id;
Expand Down
18 changes: 17 additions & 1 deletion bootloader/src/usb_cdc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,22 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp, uint8_t dtype, uint8
return NULL;
}

/*
* USB stack crash workaround.
* See http://www.chibios.com/forum/viewtopic.php?f=25&t=4568&p=32429
* This bug is fixed in ChibiOS 18+, so the workaround does not have to be here after the OS is updated.
*/
static void sduDataReceivedProxy(USBDriver* const usbp, const usbep_t ep)
{
if (auto sdup = static_cast<SerialUSBDriver*>(usbp->out_params[ep - 1U]))
{
if (usbGetReceiveTransactionSizeX(sdup->config->usbp, sdup->config->bulk_out) > 0)
{
sduDataReceived(usbp, ep);
}
}
}

/*
* USB endpoints
*/
Expand All @@ -267,7 +283,7 @@ static const USBEndpointConfig ep2config = ///< EP1 initialization structur
USB_EP_MODE_TYPE_BULK,
NULL,
sduDataTransmitted,
sduDataReceived,
sduDataReceivedProxy,
0x0040,
0x0040,
&ep2instate,
Expand Down
10 changes: 5 additions & 5 deletions firmware/src/board/board.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,23 +171,23 @@ void restart()

void setStatusLED(bool state)
{
palWritePad(GPIOE, GPIOE_LED_STATUS, !state);
palWritePad(GPIOE, GPIOE_LED_STATUS, std::uint8_t(!state));
}

void setTrafficLED(bool state)
{
palWritePad(GPIOE, GPIOE_LED_TRAFFIC, !state);
palWritePad(GPIOE, GPIOE_LED_TRAFFIC, std::uint8_t(!state));
}

void enableCANPower(bool state)
{
palWritePad(GPIOA, GPIOA_CAN_POWER_DIS, !state);
palWritePad(GPIOB, GPIOB_LED_CAN_POWER_DIS, !state);
palWritePad(GPIOA, GPIOA_CAN_POWER_DIS, std::uint8_t(!state));
palWritePad(GPIOB, GPIOB_LED_CAN_POWER_DIS, std::uint8_t(!state));
}

void enableCANTerminator(bool state)
{
palWritePad(GPIOB, GPIOB_CAN_TERMINATOR_EN, state);
palWritePad(GPIOB, GPIOB_CAN_TERMINATOR_EN, std::uint8_t(state));
}

float getBusVoltage()
Expand Down
20 changes: 18 additions & 2 deletions firmware/src/usb_cdc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,22 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp, uint8_t dtype, uint8
return NULL;
}

/*
* USB stack crash workaround.
* See http://www.chibios.com/forum/viewtopic.php?f=25&t=4568&p=32429
* This bug is fixed in ChibiOS 18+, so the workaround does not have to be here after the OS is updated.
*/
static void sduDataReceivedProxy(USBDriver* const usbp, const usbep_t ep)
{
if (auto sdup = static_cast<SerialUSBDriver*>(usbp->out_params[ep - 1U]))
{
if (usbGetReceiveTransactionSizeX(sdup->config->usbp, sdup->config->bulk_out) > 0)
{
sduDataReceived(usbp, ep);
}
}
}

/*
* USB endpoints
*/
Expand All @@ -265,7 +281,7 @@ static const USBEndpointConfig ep2config = ///< EP1 initialization structur
USB_EP_MODE_TYPE_BULK,
NULL,
sduDataTransmitted,
sduDataReceived,
sduDataReceivedProxy,
0x0040,
0x0040,
&ep2instate,
Expand Down Expand Up @@ -299,7 +315,7 @@ static void usb_event(USBDriver* usbp, usbevent_t event)
chSysLockFromISR();

/*
* Enables the endpoints specified into the configuration.
* Enables the endpoints specified in the configuration.
* Note, this callback is invoked from an ISR so I-Class functions
* must be used.
*/
Expand Down

0 comments on commit 1a8187a

Please sign in to comment.