Last active
May 31, 2019 20:53
-
-
Save JNeiger/04614be0ac46d0f425ca1058c61347b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mtrain.hpp" | |
#include "bsp.h" | |
#include <unistd.h> | |
#include "PinDefs.hpp" | |
USBD_HandleTypeDef USBD_Device; | |
// Doesn't crash | |
// DigitalOut l1 = DigitalOut(LED2); | |
int main() { | |
USBD_Init(&USBD_Device, &VCP_Desc, 0); | |
USBD_RegisterClass(&USBD_Device, USBD_CDC_CLASS); | |
USBD_CDC_RegisterInterface(&USBD_Device, &USBD_CDC_fops); | |
USBD_Start(&USBD_Device); | |
// Crashes | |
//DigitalOut l1 = DigitalOut(LED2); | |
// Doesn't crash | |
//static DigitalOut l1 = DigitalOut(LED2); | |
// Doesn't crash | |
//DigitalOut* l1 = new DigitalOut(LED2); | |
// Doesn't crash | |
//GPIO_InitTypeDef pin_structure = {}; | |
//pin_structure.Pin = LED2.pin; | |
//pin_structure.Mode = PinMode::PushPull; | |
//pin_structure.Pull = PullType::PullNone; | |
//pin_structure.Speed = PinSpeed::Low; | |
//HAL_GPIO_Init(LED2.port, &pin_structure); | |
fflush(stdout); | |
for (;;) { | |
HAL_Delay(5); | |
printf("t\r\n"); | |
fflush(stdout); | |
} | |
} | |
extern "C" { | |
int _write(int file, char *data, int len) | |
{ | |
if (file == STDOUT_FILENO) { | |
USBD_CDC_SetTxBuffer(&USBD_Device, (uint8_t*)data, len); | |
USBD_CDC_TransmitPacket(&USBD_Device); | |
} | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment