R2R
Macros | Functions | Variables
r2r.h File Reference

Main R2R library header. More...

#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "sensorlib/i2cm_drv.h"
#include "sensorlib/hw_mpu6050.h"
#include "sensorlib/mpu6050.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/gpio.h"
#include "driverlib/pin_map.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/debug.h"
#include "driverlib/interrupt.h"
#include "driverlib/i2c.h"
#include "driverlib/sysctl.h"
#include "driverlib/pwm.h"
#include "driverlib/timer.h"
#include "driverlib/uart.h"
#include "driverlib/ssi.h"
#include "driverlib/systick.h"
#include "driverlib/adc.h"
#include "utils/uartstdio.h"

Go to the source code of this file.

Macros

#define MOTOR1   1
 
#define MOTOR2   2
 

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 customTimersInit (void)
 Initializes custom timers. More...
 
void TIMER6IntHandler (void)
 Custom timer 6. More...
 
void TIMER7IntHandler (void)
 Custom timer 7. More...
 
void delayMS (int ms)
 Stops the processor for a given amount of time. This is an approximate time. More...
 
void timeInit (void)
 Initializes the general purpose systick timer. More...
 
uint32_t getTime (void)
 Returns the time in microseconds. More...
 
void timeInt (void)
 The general purpose timer interrupt function. More...
 

Variables

uint32_t ui32SysClock
 
uint32_t micros
 

Detailed Description

Main R2R library header.

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

◆ customTimersInit()

void customTimersInit ( void  )

Initializes custom timers.

This function initializes timers 6 and 7 at preset frequencies as defined in r2r.c

Parameters
Void
Returns
Void

◆ 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

◆ TIMER6IntHandler()

void TIMER6IntHandler ( void  )

Custom timer 6.

This function executes at the rate set by TIMER_6_FREQ set in r2r.c This function does not have to be called anywhere. This function does not return any values

Example:

 void TIMER6IntHandler() {

    // add custom controller code here

     }
Parameters
Void
Returns
Void

◆ TIMER7IntHandler()

void TIMER7IntHandler ( void  )

Custom timer 7.

This function executes at the rate set by TIMER_6_FREQ set in r2r.c This function does not have to be called anywhere.

Parameters
Void
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