R2R
Functions
r2r.c File Reference

Main R2R library. More...

#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <math.h>
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_sysctl.h"
#include "inc/hw_types.h"
#include "inc/hw_i2c.h"
#include "inc/hw_gpio.h"
#include "driverlib/fpu.h"
#include "driverlib/ssi.h"
#include "driverlib/pwm.h"
#include "driverlib/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/debug.h"
#include "driverlib/timer.h"
#include "driverlib/interrupt.h"
#include "driverlib/i2c.h"
#include "driverlib/uart.h"
#include "driverlib/sysctl.h"
#include "r2r.h"
#include "Encoder.h"
#include "Motor.h"
#include "PositionControl.h"
#include "CurrentControl.h"
#include "Utilities.h"

Functions

void r2rDefaultInit (void)
 Initializes the default connections for the R2R project. More...
 
void sysInit (void)
 Initializes the system clock and the master interrupts for the R2R project. More...
 
void uartInit (void)
 Initializes the UART for 115200 Baud Rate and 8-N-1 transfer rate. More...
 
void UART0read (char *message, int maxLength)
 Reads input from UART. More...
 
void UART0write (const char *string)
 Writes output from UART. More...
 
void delayMS (int ms)
 Stops the processor for a given amount of time. This is an approximate time. More...
 
void timeInit ()
 Initializes the general purpose systick timer. More...
 
void timeInt ()
 The general purpose timer interrupt function. More...
 
uint32_t getTime ()
 Returns the time in microseconds. More...
 

Detailed Description

Main R2R library.

This file contains system functions for the R2R Project, including functions related to system initializations, UART, and debugging.

Author
Benjamen Lim
Huan Weng

Function Documentation

◆ delayMS()

void delayMS ( int  ms)

Stops the processor for a given amount of time. This is an approximate time.

Parameters
msmilliseconds
Returns
Void

◆ getTime()

uint32_t getTime ( void  )

Returns the time in microseconds.

This function can be used for delays as an alternative to delayMS() because it is interrupt-based.

Example:

    uint32_t curr_time = getTime();
...
uint32_t time_taken = getTime()-curr_time;
Parameters
usmicroseconds
Returns
Void

◆ r2rDefaultInit()

void r2rDefaultInit ( void  )

Initializes the default connections for the R2R project.

This function initializes all peripherals and GPIO pins. This function only needs to be called in main once.

Example:

int main() {
    r2rDefaultInit();
}
Parameters
Void
Returns
Void

◆ sysInit()

void sysInit ( void  )

Initializes the system clock and the master interrupts for the R2R project.

Parameters
Void
Returns
Void

◆ timeInit()

void timeInit ( void  )

Initializes the general purpose systick timer.

Parameters
Void
Returns
Void

◆ timeInt()

void timeInt ( void  )

The general purpose timer interrupt function.

This function is called every microsecond and updates a counter.

Parameters
msmilliseconds
Returns
Void

◆ UART0read()

void UART0read ( char *  message,
int  maxLength 
)

Reads input from UART.

Parameters
char*message pointer to a buffer
intmaxLength the maximum length of the buffer
Returns
Void

◆ UART0write()

void UART0write ( const char *  string)

Writes output from UART.

Parameters
constchar* message pointer to a buffer
Returns
Void

◆ uartInit()

void uartInit ( void  )

Initializes the UART for 115200 Baud Rate and 8-N-1 transfer rate.

Parameters
Void
Returns
Void