On this page
Hello_World
Make sure you have the the TTL to usb adapter connected to uart2 on the
type-c
[link_to_page](3b7f0872-f00d-41cf-857e-646938c49bd0)
imports all the libraries that will be used
#include "tap/board/board.hpp"
#include "drivers_singleton.hpp"
#include "tap/communication/serial/uart_terminal_device.hpp"// allows for printf
use namespace tap::communication::serial
for ease of use
using namespace tap::communication::serial;
get drivers and initialize the type-c
src::Drivers *drivers = src::DoNotUse_getDrivers(); // gets the driver object
Board::initialize(); // initialize the whole board
initialize the UartTerimalDevice
object and IOStream
object.
These two objects are what allow us to print through Uart2
on the type-c
UartTerminalDevice ter(drivers);
ter.initialize();
modm::IOStream s(ter);
print “Hello world” and sleep for 500ms
s.printf("Hello world\n"); // print hello world
modm::delay_ms(500); // sleep for 500 ms
Code:
#include "tap/board/board.hpp"
#include "drivers_singleton.hpp"
#include "tap/communication/serial/uart_terminal_device.hpp"
using namespace tap::communication::serial;
int main(){
src::Drivers *drivers = src::DoNotUse_getDrivers();// gets the driver object
Board::initialize(); // intalize the whole board
UartTerminalDevice ter(drivers);
ter.initialize();
modm::IOStream s(ter);
while(true){
s.printf("Hello world\n");
modm::delay_ms(500);
}
}
to upload to the type-c press
ctrl+shift+B
click on serial monitor
on the bottom bar
select the usb port the type-c is plugged in it should look like this:
if you don’t see the TTL to USB device on windows you need to install the drivers for it.
Follow the guide here to install the drivers: https://www.pololu.com/docs/0j7/all
then hit Start Monitoring