Urbanite: Parking aid system
port_system.h File Reference

: Header for port_system.c file. More...

#include <stdint.h>

Functions

uint32_t port_system_init (void)
 Initializes the system.
 
uint32_t port_system_get_millis (void)
 Returns the number of milliseconds since the system started. More...
 
void port_system_set_millis (uint32_t ms)
 Sets the number of milliseconds since the system started. More...
 
void port_system_delay_ms (uint32_t ms)
 Delays the program execution for the specified number of milliseconds. More...
 
void port_system_delay_until_ms (uint32_t *t, uint32_t ms)
 Delays the program execution until the specified number of milliseconds since the system started. More...
 
void port_system_power_stop (void)
 Set the system in stop mode for low power consumption. More...
 
void port_system_power_sleep (void)
 Set the system in sleep mode for low power consumption. More...
 
void port_system_sleep (void)
 Enable low power consumption in sleep mode. More...
 
void port_system_systick_resume (void)
 Resume Tick increment. More...
 
void port_system_systick_suspend (void)
 Suspend Tick increment. More...
 

Detailed Description

: Header for port_system.c file.

Attention

Josué Pagán Ortiz (j.pag.nosp@m.an@u.nosp@m.pm.es) Sistemas Digitales II

Function Documentation

◆ port_system_delay_ms()

void port_system_delay_ms ( uint32_t  ms)

Delays the program execution for the specified number of milliseconds.

Parameters
msNumber of milliseconds to delay.

◆ port_system_delay_until_ms()

void port_system_delay_until_ms ( uint32_t *  t,
uint32_t  ms 
)

Delays the program execution until the specified number of milliseconds since the system started.

Parameters
tPointer to the variable that stores the number of milliseconds to delay until.
msNumber of milliseconds to delay until.
Note
This function modifies the value of the variable pointed by t to the number of milliseconds to delay until.
This function is useful to implement periodic tasks.

◆ port_system_get_millis()

uint32_t port_system_get_millis ( void  )

Returns the number of milliseconds since the system started.

Return values
numberof milliseconds since the system started.

◆ port_system_power_sleep()

void port_system_power_sleep ( void  )

Set the system in sleep mode for low power consumption.

The function sets the state of the power regulator in sleep mode.
After that, the function sets the system mode in sleep mode, to enter in sleep mode when calling __WFI() (wait for interruption).
The system remains in this line until an external interruption or timer interruption occurs.

ONLY IF YOU NEED IT! TODO alumnos Version 4:

✅ 1. Copy the following code in the file stm32f4_system.c.

{
MODIFY_REG(PWR->CR, (PWR_CR_PDDS | PWR_CR_LPDS), PWR_CR_LPDS); // Select the regulator state in Stop mode: Set PDDS and LPDS bits according to PWR_Regulator value
SCB->SCR &= ~((uint32_t)SCB_SCR_SLEEPDEEP_Msk); // Reset SLEEPDEEP bit of Cortex System Control Register
__WFI(); // Select Sleep mode entry : Request Wait For Interrupt
}

◆ port_system_power_stop()

void port_system_power_stop ( void  )

Set the system in stop mode for low power consumption.

The function sets the state of the power regulator in stop mode.
After that, the function sets the system mode in sleep mode, to enter in stop mode when calling __WFI() (wait for interruption).
The system remains in this line until an external interruption or timer interruption occurs.
If an interruption occurs the system wakes up and resets the system mode.

TODO alumnos Version 4:

✅ 1. Copy the following code in the file stm32f4_system.c.

{
MODIFY_REG(PWR->CR, (PWR_CR_PDDS | PWR_CR_LPDS), PWR_CR_LPDS); // Select the regulator state in Stop mode: Set PDDS and LPDS bits according to PWR_Regulator value
SCB->SCR |= ((uint32_t)SCB_SCR_SLEEPDEEP_Msk); // Set SLEEPDEEP bit of Cortex System Control Register
__WFI(); // Select Stop mode entry : Request Wait For Interrupt
SCB->SCR &= ~((uint32_t)SCB_SCR_SLEEPDEEP_Msk); // Reset SLEEPDEEP bit of Cortex System Control Register
}

◆ port_system_set_millis()

void port_system_set_millis ( uint32_t  ms)

Sets the number of milliseconds since the system started.

Parameters
msNew number of milliseconds since the system started.

◆ port_system_sleep()

void port_system_sleep ( void  )

Enable low power consumption in sleep mode.

TODO alumnos Version 4:

✅ 1. Call function port_system_systick_suspend() to suspend the count of the SysTick.
✅ 2. Call function port_system_power_sleep() to enter sleep in sleep mode.

◆ port_system_systick_resume()

void port_system_systick_resume ( void  )

Resume Tick increment.

The SysTick timer is the source of time base. It is used to generate interrupts at regular time intervals. Once this function is called, the SysTick interrupt will be enabled and so Tick increment is resumed.

TODO alumnos Version 4:

✅ 1. Copy the following code in the file stm32f4_system.c.

{
SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
}

◆ port_system_systick_suspend()

void port_system_systick_suspend ( void  )

Suspend Tick increment.

The SysTick timer is the source of time base. It is used to generate interrupts at regular time intervals. Once this function is called, the SysTick interrupt will be disabled so it saves more energy and it does not generate any interruption.

TODO alumnos Version 4:

✅ 1. Copy the following code in the file stm32f4_system.c.

{
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
}
port_system_systick_suspend
void port_system_systick_suspend(void)
Suspend Tick increment.
Definition: stm32f4_system.c:329
port_system_power_stop
void port_system_power_stop(void)
Set the system in stop mode for low power consumption.
Definition: stm32f4_system.c:335
port_system_power_sleep
void port_system_power_sleep(void)
Set the system in sleep mode for low power consumption.
Definition: stm32f4_system.c:350
port_system_systick_resume
void port_system_systick_resume(void)
Resume Tick increment.
Definition: stm32f4_system.c:323