Skip to content

Instantly share code, notes, and snippets.

@JNeiger
Last active June 1, 2019 16:56
Show Gist options
  • Save JNeiger/d21aef45f3ea5c2cda3cb267b4059142 to your computer and use it in GitHub Desktop.
Save JNeiger/d21aef45f3ea5c2cda3cb267b4059142 to your computer and use it in GitHub Desktop.
#include "mtrain.hpp"
#include "bsp.h"
#include <unistd.h>
#include "PinDefs.hpp"
USBD_HandleTypeDef USBD_Device;
class TempObj {
public:
TempObj() {}
~TempObj() {}
};
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);
TempObj t = TempObj();
fflush(stdout);
for (;;) {
HAL_Delay(50);
HAL_Delay(50);
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