ESR-2025/main.c

52 lines
1.3 KiB
C
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file main.c
* @brief UART console, interrupt-driven 4×4 keypad input, and Morse LED blink on MSP430FR2355.
*
* Initializes peripheral modules and enters low-power mode, waking on keypress
* interrupts to blink Morse code on LED and echo keys over UART.
*
* @date 2025-07-02
*/
#include <msp430.h>
#include <driverlib.h>
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
#include "src/keypad.h"
#include "src/morse.h"
#include "src/i2c.h"
#include "src/lcd.h"
#include "src/Board.h"
#include "src/timer.h"
#include "src/state_machine.h"
/** On-board LED port and pin (used by Morse module) */
#define LED_PORT GPIO_PORT_P1 /**< On-board LED port */
#define LED_PIN GPIO_PIN0 /**< On-board LED pin */
/**
* @brief Main application entry point.
*
* Sets up GPIO, UART, keypad interrupts, and enters low-power loop.
* On keypress, echoes key over UART.
*
* @return Never returns
*/
int main(void)
{
/* Stop watchdog and unlock GPIO pins */
WDT_A_hold(WDT_A_BASE);
PMM_unlockLPM5();
/* Initialize on-board LED (used by Morse blinking) */
GPIO_setAsOutputPin(LED_PORT, LED_PIN);
GPIO_setOutputLowOnPin(LED_PORT, LED_PIN);
init_timer();
i2c_init();
lcd_init();
sm_init();
sm_loop();
}