NavHAL 0.1.0
NAVRobotec's architecture-agnostic HAL for embedded systems.
Loading...
Searching...
No Matches
test_gpio.h File Reference

GPIO unit test declarations for NAVHAL. More...

#include "unity.h"
#include <stdint.h>
Include dependency graph for test_gpio.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define TEST_PIN   GPIO_PC09
 GPIO pin used for all tests (PC9)
#define TEST_AF   GPIO_AF07
 Alternate function number used for testing (AF7)

Functions

void test_hal_gpio_setmode (void)
 Test GPIO mode configuration.
void test_hal_gpio_getmode (void)
 Test GPIO mode reading.
void test_hal_gpio_digitalwrite_sets_pin_high (void)
 Test digital write high.
void test_hal_gpio_digitalwrite_sets_pin_low (void)
 Test digital write low.
void test_gpio_set_alternate_function (void)
 Test alternate function configuration.

Detailed Description

GPIO unit test declarations for NAVHAL.

This header defines the test cases for verifying GPIO functionality in the NAVHAL hardware abstraction layer. It includes tests for:

  • Mode configuration (input/output/alternate)
  • Digital write operations
  • Alternate function setup
Note
Uses Unity test framework for assertions

Macro Definition Documentation

◆ TEST_AF

#define TEST_AF   GPIO_AF07

Alternate function number used for testing (AF7)

◆ TEST_PIN

#define TEST_PIN   GPIO_PC09

GPIO pin used for all tests (PC9)

Function Documentation

◆ test_gpio_set_alternate_function()

void test_gpio_set_alternate_function ( void )

Test alternate function configuration.

Verifies hal_gpio_set_alternate_function() correctly:

  • Configures pin for alternate function
  • Sets the specified function number
  • Maintains other pin settings

Verifies that hal_gpio_set_alternate_function():

  1. Correctly sets the alternate function number
  2. Handles both AFRL (pins 0-7) and AFRH (pins 8-15) registers

Test sequence:

  1. Configure pin for alternate function
  2. Verify correct AF number in appropriate register (AFRL/AFRH)

◆ test_hal_gpio_digitalwrite_sets_pin_high()

void test_hal_gpio_digitalwrite_sets_pin_high ( void )

Test digital write high.

Verifies hal_gpio_digitalwrite() correctly:

  • Sets pin to logic high
  • Maintains state until changed

Test digital write high.

Verifies that hal_gpio_digitalwrite() with GPIO_HIGH:

  1. Sets the correct bit in the ODR register
  2. Actually drives the pin high

Test sequence:

  1. Configure pin as output
  2. Write high
  3. Verify ODR register state

◆ test_hal_gpio_digitalwrite_sets_pin_low()

void test_hal_gpio_digitalwrite_sets_pin_low ( void )

Test digital write low.

Verifies hal_gpio_digitalwrite() correctly:

  • Sets pin to logic low
  • Maintains state until changed

Test digital write low.

Verifies that hal_gpio_digitalwrite() with GPIO_LOW:

  1. Clears the correct bit in the ODR register
  2. Actually drives the pin low

Test sequence:

  1. Configure pin as output
  2. Write low
  3. Verify ODR register state

◆ test_hal_gpio_getmode()

void test_hal_gpio_getmode ( void )

Test GPIO mode reading.

Verifies hal_gpio_getmode() correctly returns:

Verifies that hal_gpio_getmode() correctly returns:

  1. The current pin mode configuration
  2. Matches the actual hardware register state

Test sequence:

  1. Configure pin as output
  2. Compare getmode() return value with direct register read

◆ test_hal_gpio_setmode()

void test_hal_gpio_setmode ( void )

Test GPIO mode configuration.

Verifies hal_gpio_setmode() correctly configures:

  • Input/output modes
  • Pull-up/pull-down settings

Verifies that hal_gpio_setmode() correctly configures:

  1. The pin mode in the MODER register
  2. The pull-up/pull-down settings

Test sequence:

  1. Configure pin as output with no pull-up/pull-down
  2. Verify MODER register bits are set correctly