Skip to content
Snippets Groups Projects
Commit 79213e35 authored by Leonardo Martinez Hornak's avatar Leonardo Martinez Hornak
Browse files

gpio and userinterface modules created

parent e1e8ef5d
Branches
Tags
No related merge requests found
/**
* @file common.h
* @brief Proyecto SmartWatch - Sistemas Embebidos - Fing
* Common definitions file
*
* @author Leonardo Martínez <leonardo.martinez.hornak@fing.edu.uy>, Isabel Morales <imorales@fing.edu.uy>
* @version 1.0
* @date 15/5/2021
*/
#ifndef INCLUDE_COMMON_H_
#define INCLUDE_COMMON_H_
//#define DEBUG
#endif /* INCLUDE_COMMON_H_ */
/**
* @file gpio.h
* @brief GPIO Module header
*
* Proyecto Smart Watch - GPIO
* GPIO module
*
* This module is used to configure the
* GPIOS, modify LED states and get notifications for button touches
*
* gpio.h
* Modules that allows the configuration of the GPIOs and getting the state of the
* buttons.
*
* @authors Leonardo Martínez <leonardo.martinez.hornak@fing.edu.uy>, Isabel Morales <imorales@fing.edu.uy>
* @version 1.0
* @date May 15, 2021
*/
#ifndef INCLUDE_GPIO_H_
#define INCLUDE_GPIO_H_
/**
* Constants shared with other modules
*/
enum leds {LED_ONE, LED_RED, LED_GREEN, LED_BLUE};
/**
* @brief Initializes all ports according to connection to MSP432 Launchpad and to save power of unused pins
*
*/
void initializeGPIOModule(void);
/**
* @brief Turn on LED specified by the identifier
* @param int identifier: name of the LED as defined .common.h
*
*/
void turnOnLED(int identifier);
/**
* @brief Turn off LED specified by the identifier
* @param int identifier: name of the LED as defined .common.h
*
*/
void turnOffLED(int identifier);
/**
* @brief Sets callback function to be added from this module to the function queue
* @param void* callback_function: function to be called when the bluetooth init button is pressed
*
*/
void setBluetoothButtonISRCallbackFunction(void *callback_function);
#endif /* INCLUDE_GPIO_H_ */
/**
* @file user_interface.h
* @brief User Interface Module header
*
* Proyecto Smart Watch - User Interface
* User Interface module
*
* This module is used to implement
* the user interface of the smart watch.
* This means, setting the states of the LEDs and
* reacting to interrupts from the buttons. It behaves as an interface between
* the smartwatch and the hardware dependent module
*
* user_interface.h
* Modules that allows the configuration of the LEDs and getting the state of the
* buttons.
*
* @authors Leonardo Martínez <leonardo.martinez.hornak@fing.edu.uy>, Isabel Morales <imorales@fing.edu.uy>
* @version 1.0
* @date May 15, 2021
*/
#ifndef INCLUDE_USER_INTERFACE_H_
#define INCLUDE_USER_INTERFACE_H_
/**
* Constants shared with other modules
*/
/**
* @brief Turns on device alarm LED
* @param Color c: Sets LED color to turn on
*/
void turnOnAlarmLED(void);
/**
* @brief Turns off device alarm LED
*/
void turnOffAlarmLED(void);
/**
* @brief Turns on debug LED
*/
void turnOnDebugLED(void);
/**
* @brief Turns off debug LED
*/
void turnffDebugLED(void);
#endif /* INCLUDE_USER_INTERFACE_H_ */
/Debug/
#include "msp.h"
#include "user_interface.h"
#include "gpio.h"
/**
* main.c
*/
void main(void)
{
int i;
volatile int i;
WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD; // stop watchdog timer
while(1)
{
initializeGPIOModule();
for(i = 0; i++; i<1000);
for(i = 0; i++; i<1000);
while(1)
{
turnOnAlarmLED();
turnOffAlarmLED();
}
}
#include "msp.h"
#include "gpio.h"
void initializeGPIOModule(void)
{
//Configures Port1 pins according to SLAU597F (MSP432 Launchpad User Guide)
P1DIR = 0b11101001;
P1SEL1 = 0b0000000;
P1SEL0 = 0b1110110;
P2DIR = 0b11111111;
P2SEL1 = 0b00000000;
P2SEL0 = 0b11110000;
//TODO Configure other ports
}
void turnOnLED(int identifier)
{
switch (identifier)
{
case LED_ONE:
P1OUT |= BIT0;
break;
case LED_RED:
P2OUT |= BIT0;
break;
case LED_GREEN:
P2OUT |= BIT1;
break;
case LED_BLUE:
P2OUT |= BIT2;
break;
}
}
void turnOffLED(int identifier)
{
switch (identifier)
{
case LED_ONE:
P1OUT &= ~BIT0;
break;
case LED_RED:
P2OUT &= ~BIT0;
break;
case LED_GREEN:
P2OUT &= ~BIT1;
break;
case LED_BLUE:
P2OUT &= ~BIT2;
break;
}
}
void setBluetoothButtonISRCallbackFunction(void *callback_function)
{}
#include "user_interface.h"
#include "gpio.h"
void turnOnAlarmLED(void)
{
turnOnLED(LED_RED);
}
void turnOffAlarmLED(void)
{
turnOffLED(LED_RED);
}
void turnOnDebugLED(void)
{
turnOnLED(LED_ONE);
}
void turnffDebugLED(void)
{
turnOffLED(LED_ONE);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment