Skip to content

Commit

Permalink
moved usart_ports_c and renamed it in all files
Browse files Browse the repository at this point in the history
  • Loading branch information
itzandroidtab committed May 3, 2019
1 parent 33c9e96 commit 578d3c5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 24 deletions.
13 changes: 11 additions & 2 deletions code/headers/hardware_usart.hpp
Expand Up @@ -6,12 +6,21 @@
#include <usart_connection.hpp>

namespace r2d2::usart {
enum class usart_ports_c {
uart0,
uart1,
uart2,
uart3,
// only for determining how many uart ports there are
UART_SIZE
};

class hardware_usart_c : public usart_connection_c {
private:
Usart *hardware_usart = nullptr;
unsigned int baudrate;
bool usart_initialized = true;
uart_ports_c usart_port;
usart_ports_c usart_port;
queue_c<uint8_t, 250> input_buffer;

/// @brief check if the transmitter is ready to send
Expand All @@ -27,7 +36,7 @@ namespace r2d2::usart {
uint8_t receive_byte();

public:
hardware_usart_c(unsigned int baudrate, uart_ports_c usart_port);
hardware_usart_c(unsigned int baudrate, usart_ports_c usart_port);
/// @brief char output operator
///
/// Although calling send_byte should do the exact same thing.
Expand Down
3 changes: 1 addition & 2 deletions code/headers/test_usart.hpp
Expand Up @@ -10,11 +10,10 @@ namespace r2d2::usart {
class test_usart_c : public usart_connection_c {
private:
unsigned int baudrate;
uart_ports_c usart_port;
queue_c<uint8_t, 250> input_buffer;

public:
test_usart_c(unsigned int baudrate, uart_ports_c usart_port);
test_usart_c(unsigned int baudrate);

/// @brief does not actualy disable anything
void enable() override;
Expand Down
14 changes: 0 additions & 14 deletions code/headers/uart_ports.hpp

This file was deleted.

10 changes: 5 additions & 5 deletions code/src/hardware_usart.cpp
Expand Up @@ -17,9 +17,9 @@ namespace r2d2::usart {
}

hardware_usart_c::hardware_usart_c(unsigned int baudrate,
uart_ports_c usart_port)
usart_ports_c usart_port)
: baudrate(baudrate), usart_port(usart_port) {
if (usart_port == uart_ports_c::uart1) {
if (usart_port == usart_ports_c::uart1) {

hardware_usart = USART0;

Expand All @@ -29,7 +29,7 @@ namespace r2d2::usart {
PIOA->PIO_ABSR &= ~PIO_PA11;

PMC->PMC_PCER0 = (0x01 << ID_USART0);
} else if (usart_port == uart_ports_c::uart2) {
} else if (usart_port == usart_ports_c::uart2) {
hardware_usart = USART1;

PIOA->PIO_PDR = PIO_PA12;
Expand All @@ -38,7 +38,7 @@ namespace r2d2::usart {
PIOA->PIO_ABSR &= ~PIO_PA13;

PMC->PMC_PCER0 = (0x01 << ID_USART1);
} else if (usart_port == uart_ports_c::uart3) {
} else if (usart_port == usart_ports_c::uart3) {

hardware_usart = USART3;

Expand All @@ -48,7 +48,7 @@ namespace r2d2::usart {
PIOD->PIO_ABSR |= PIO_PD5;

PMC->PMC_PCER0 = (0x01 << ID_USART3);
} else if (usart_port == uart_ports_c::uart0) {
} else if (usart_port == usart_ports_c::uart0) {

// NO! its probably not a good idea to use this, it is already in
// use by the hwlib::cout stuff hardware_usart = UART; PIOA->PIO_PDR
Expand Down
2 changes: 1 addition & 1 deletion code/src/test_usart.cpp
@@ -1,7 +1,7 @@
#include <test_usart.hpp>

namespace r2d2::usart {
test_usart_c::test_usart_c(unsigned int baudrate, uart_ports_c usart_port)
test_usart_c::test_usart_c(unsigned int baudrate)
: baudrate(baudrate) {
}

Expand Down

0 comments on commit 578d3c5

Please sign in to comment.