# benshuttle28/ece1188-design-project1 architecture

> Architecture diagram of the GitHub repository benshuttle28/ece1188-design-project1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/benshuttle28/ece1188-design-project1
- Repository: https://github.com/benshuttle28/ece1188-design-project1

## Overview

##### Project Type and Purpose
- This project is an embedded system designed for a line-following race challenge. It is aimed at controlling a robot's behavior using modularized code that abstracts sensor and actuator functionalities.
- The README mentions that the project is for “Design Challenge #1: Line Following Race,” which suggests that the architecture must support real-time sensor input processing and motor control.

##### File Structure
- At the top level, several critical files (Clock.c, Reflectance.c, CortexM.c, etc.) set up system-level functionality.
- The project is divided into meaningful modules:
- The "Modules" folder contains sub-folders for:
◦ BumpSwitches – manages bump sensor inputs.
◦ FSM – houses the finite state machine implementation used for decision-making.
◦ Motors – implements motor control functions, including PWM and timers.
- The "Integration" folder contains main.c, which acts as the entry point for the application logic running on the robot.
- Additionally, files like system_msp432p401r.c, startup_msp432p401r_ccs.c, and targetConfigs (with the MSP432P401R configuration) indicate that the project targets a specific microcontroller platform. The project leverages an RTOS or bare-metal programming environment specific to this hardware.

##### Extracting Insights from the README
- The README reinforces that the main modules control different physical and logical aspects of the robot (sensors, state transitions, and motors).
- The separation of concerns in the file system hints at a modular architecture where each component is designed to handle a distinct piece of the overall behavior.

a. Main Components:
- Microcontroller/Hardware Layer: represented by the msp432 platform (system_msp432p401r, startup, targetConfigs).
- System Layer: Low-level drivers and system clock (Clock.c, CortexM.c, Reflectance.c).
- Modules:
- BumpSwitches: Handles bump sensor functionality.
- FSM: Manages the high-level control flow via a finite state machine.
- Motors: Controls PWM, motor operations, and timer functions.
- Integration Layer: The main application (Integration/main.c) which ties together sensor inputs and control logic from different modules.

b. Relationships and Interactions:
- Have blocks for “Low-Level Drivers” (Clock, CortexM, Reflectance) feeding into the “Modules.”
- Among the modules, show directional connections from sensor modules (BumpSwitches) and state machine logic (FSM) into the Motors module (i.e., Motor control decisions).
- The "Integration" component (main.c) sits at the top level, orchestrating and initializing these modules.
- Sensor data from BumpSwitches and Reflectance going into the FSM.
- Decisions made in the FSM that trigger signals to the Motors.
- Feedback loops where motor feedback (via sensors) might update the FSM.

c. Architectural Patterns and Principles:
- Separation of concerns: distinct modules for sensor reading, control logic, and actuation.
- That the architecture likely uses an event-driven or state-machine pattern (FSM), typical in embedded real-time systems.

d. Relevant Technologies:
- Use of the MSP432 microcontroller (with related startup and configuration files).
- Mention that implementations use C-based drivers and libraries tailored for real-time embedded control.
- Development/deployment environments (noted by Eclipse project files like .cproject and .ccsproject).

##### Instructing Specific Elements
- Each component (Hardware Layer, Low-Level Drivers, BumpSwitches, FSM, Motors, Integration/main) should have a clear label.
- If possible, include annotations or legends:
- Be very detailed in capturing components like system startup, configuration files, low-level drivers, and how modules combine to form a cohesive control system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Main["Integration/Application Entry Point"]:::integration
    HW["Microcontroller/Hardware Layer"]:::hardware
    LL["Low-Level Drivers"]:::driver
    Bump["Bump Sensor Module (BumpSwitches)"]:::module
    FSM["Finite State Machine Module (FSM)"]:::module
    Motors["Motor Control Module (Motors)"]:::module

    Main -->|"init"| HW
    Main -->|"init"| LL
    Main -->|"init"| Bump
    Main -->|"init"| FSM
    Main -->|"init"| Motors

    HW -->|"hardwareSupport"| LL
    LL -->|"sensorData"| Bump
    LL -->|"sensorData"| FSM
    Bump -->|"bumpTrigger"| FSM
    FSM -->|"stateCommands"| Motors

    %% Click Events for Microcontroller/Hardware Layer
    click HW "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/system_msp432p401r.c"
    click HW "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/startup_msp432p401r_ccs.c"
    click HW "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/msp432p401r.cmd"
    click HW "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/targetConfigs/MSP432P401R.ccxml"

    %% Click Events for Low-Level Drivers
    click LL "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/Clock.c"
    click LL "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/CortexM.c"
    click LL "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/Reflectance.c"
    click LL "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/SysTickInts.c"

    %% Click Events for Bump Sensor Module
    click Bump "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/Modules/BumpSwitches/bump.c"
    click Bump "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/Modules/BumpSwitches/bump.h"

    %% Click Events for Finite State Machine Module
    click FSM "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/Modules/FSM/fsm.c"
    click FSM "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/Modules/FSM/fsm.h"
    click FSM "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/Modules/FSM/MotorFSM.h"

    %% Click Events for Motor Control Module
    click Motors "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/Modules/Motors/Motor.c"
    click Motors "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/Modules/Motors/PWM.c"
    click Motors "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/Modules/Motors/TimerA1.c"

    %% Click Event for Integration/Application Entry Point
    click Main "https://github.com/benshuttle28/ece1188-design-project1/blob/main/DesignProject1/Integration/main.c"

    %% Styles
    classDef hardware fill:#ffcccc,stroke:#990000,stroke-width:2px;
    classDef driver fill:#ccffcc,stroke:#009900,stroke-width:2px;
    classDef module fill:#cce5ff,stroke:#003366,stroke-width:2px;
    classDef integration fill:#ffffcc,stroke:#cccc00,stroke-width:2px;
```
