Skip to content

Commit

Permalink
Merge pull request #88 from ruuvi/update-modules
Browse files Browse the repository at this point in the history
3.29.0 refactor
  • Loading branch information
ojousima authored Sep 9, 2020
2 parents 4a1b105 + afeda5b commit 7a9da7c
Show file tree
Hide file tree
Showing 111 changed files with 6,565 additions and 8,344 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "ruuvi.libraries.c"]
path = src/ruuvi.libraries.c
url = https://github.com/ruuvi/ruuvi.libraries.c
[submodule "src/semver.c"]
path = src/semver
url = https://github.com/h2non/semver.c.git
13 changes: 5 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,7 @@ script:
wget -q https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip
unzip -q nRF5_SDK_15.3.0_59ac345.zip
fi
- |
astyle --project=".astylerc" --recursive \
"src/application_config/*.h" \
"src/tasks/*.c" \
"src/tasks/*.h" \
"src/tests/*.c" \
"src/tests/*.h"
- astyle --project=".astylerc" "src/main.c"
- make astyle
- git diff --exit-code --diff-filter=d --color
- build-wrapper-linux-x86-64 --out-dir bw-output make all
- ceedling test:all
Expand All @@ -52,6 +45,10 @@ script:
cache:
directories:
- nRF5_SDK_15.3.0_59ac345
- src/ruuvi.boards.c
- src/ruuvi.drivers.c
- src/ruuvi.endpoints.c
- src/ruuvi.libraries.c

addons:
sonarcloud:
Expand Down
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,7 @@ doxygen:
astyle:
astyle --project=".astylerc" --recursive \
"src/application_config/*.h" \
"src/tasks/*.c" \
"src/tasks/*.h" \
"src/tests/*.c" \
"src/tests/*.h" \
"test/*.c"
astyle --project=".astylerc" "src/main.c" "src/main.h"
astyle --project=".astylerc" "src/main.c" "src/main.h" \
"src/app_*.c" "src/app_*.h" \
"src/run_integration_tests.c" "src/run_integration_tests.h"
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ Document is generated with Doxygen. Run `make doxygen` to generate the docs loca
browse to [Travis built docs](ruuvi.github.io/ruuvi.firmware.c)

# Changelog
## 3.29.0
- Refactor, move tasks under drivers.
- Refactor, store log data to flash.
- Improve GATT power consumption.
- Improve GATT data rate.

## 3.28.12
- Fix leds not blinking

## 3.28.12
- Automatically release a tag

Expand Down
19 changes: 18 additions & 1 deletion project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:project:
:use_exceptions: FALSE
:use_test_preprocessor: TRUE
:use_auxiliary_dependencies: TRUE
:use_auxiliary_dependencies: FALSE
:build_root: build
# :release_build: TRUE
:test_file_prefix: test_
Expand All @@ -28,6 +28,22 @@
:extension:
:executable: .out

:tools:
# Ceedling defaults to using gcc for compiling, linking, etc.
# As [:tools] is blank, gcc will be used (so long as it's in your system path)
# See documentation to configure a given toolchain for use
:test_linker:
:executable: gcc #absolute file path
:name: 'gcc linker'
:arguments:
- ${1} #list of object files to link (Ruby method call param list sub)
- -lm #link with math header
- -o ${2} #executable file output (Ruby method call param list sub)

:tools_gcov_linker:
:arguments:
- -lm

:paths:
:test:
- +:test/**
Expand Down Expand Up @@ -63,6 +79,7 @@
:enforce_strict_ordering: TRUE
:plugins:
- :ignore
- :ignore_arg
- :callback
- :return_thru_ptr
- :array
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ VARIANTS = default longlife longmem test

.PHONY: all sync ${BOARDS} analysis publish clean

all: sync clean ${BOARDS}
all: clean ${BOARDS}

sync:
@echo Synchronizing GIT...
Expand Down
192 changes: 192 additions & 0 deletions src/app_button.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
#include "app_button.h"
#include "ruuvi_boards.h"
#include "ruuvi_driver_error.h"
#include "ruuvi_interface_gpio.h"
#include "ruuvi_interface_gpio_interrupt.h"
#include "ruuvi_interface_log.h"
#include "ruuvi_task_button.h"

/**
* @addtogroup app_button
*/
/*@{*/
/**
* @file app_button.c
* @author Otso Jousimaa <[email protected]>
* @date 2020-02-12
* @copyright Ruuvi Innovations Ltd, license BSD-3-Clause.
*/

#if RB_BUTTONS_NUMBER

static inline void LOG (const char * const msg)
{
ri_log (RI_LOG_LEVEL_INFO, msg);
}

// Find which button was pressed
#ifndef CEEDLING
static
#endif
ri_gpio_slope_t get_activation (ri_gpio_evt_t evt)
{
size_t ii;
const ri_gpio_id_t buttons[] = RB_BUTTONS_LIST;
const ri_gpio_state_t states[] = RB_BUTTONS_ACTIVE_STATE;
ri_gpio_slope_t activation;

for (ii = 0; (ii < RB_BUTTONS_NUMBER) && (buttons[ii] != evt.pin); ii++) {};

if (ii < RB_BUTTONS_NUMBER)
{
activation = (states[ii] == RI_GPIO_HIGH) ? RI_GPIO_SLOPE_LOTOHI :
RI_GPIO_SLOPE_HITOLO;
}
else
{
activation = RI_GPIO_SLOPE_UNKNOWN;
}

return activation;
}

#if RB_BUTTONS_NUMBER > 0
#ifndef CEEDLING
static
#endif
void on_button_1_press (const ri_gpio_evt_t evt)
{
ri_gpio_slope_t activation = get_activation (evt);

if (activation == evt.slope)
{
LOG ("Button 1 pressed\r\n");
}
else
{
LOG ("Button 1 released\r\n");
}
}
#endif

#if RB_BUTTONS_NUMBER > 1
#ifndef CEEDLING
static
#endif
void on_button_2_press (const ri_gpio_evt_t evt)
{
ri_gpio_slope_t activation = get_activation (evt);

if (activation == evt.slope)
{
LOG ("Button 2 pressed\r\n");
}
else
{
LOG ("Button 2 released\r\n");
}
}
#endif

#if RB_BUTTONS_NUMBER > 2
#ifndef CEEDLING
static
#endif
void on_button_3_press (const ri_gpio_evt_t evt)
{
ri_gpio_slope_t activation = get_activation (evt);

if (activation == evt.slope)
{
LOG ("Button 3 pressed\r\n");
}
else
{
LOG ("Button 3 released\r\n");
}
}
#endif

#if RB_BUTTONS_NUMBER > 3
#ifndef CEEDLING
static
#endif
void on_button_4_press (const ri_gpio_evt_t evt)
{
ri_gpio_slope_t activation = get_activation (evt);

if (activation == evt.slope)
{
LOG ("Button 4 pressed\r\n");
}
else
{
LOG ("Button 4 released\r\n");
}
}
#endif

/** @brief List of buttons to initialize. */
static const ri_gpio_id_t button_pins[] = RB_BUTTONS_LIST;
/** @brief GPIO states when button is considered active */
static const ri_gpio_state_t button_active[] = RB_BUTTONS_ACTIVE_STATE;
/** @brief Function callbacks on button presses. - TODO: Generalise for multiple buttons */
static const rt_button_fp_t app_button_handlers[RB_BUTTONS_NUMBER] =
{
#if RB_BUTTONS_NUMBER > 0
& on_button_1_press,
#endif
#if RB_BUTTONS_NUMBER > 1
& on_button_2_press,
#endif
#if RB_BUTTONS_NUMBER > 2
& on_button_3_press,
#endif
#if RB_BUTTONS_NUMBER > 3
& on_button_4_press,
#endif
};

static rt_button_init_t m_init_data =
{
.p_button_pins = button_pins,
.p_button_active = button_active,
.p_button_handlers = app_button_handlers,
.num_buttons = RB_BUTTONS_NUMBER
};

/**
* @brief Initialize buttons.
*
* After initialization buttons are powered if needed and
* the callback defined at app_button.c is called on activation.
*
* @retval RD_SUCCESS if buttons were initialized
* @retval RD_ERROR_INVALID_STATE if RI_GPIO or RI_GPIO_INTERRUPT are not initialized.
*/
rd_status_t app_button_init (void)
{
rd_status_t err_code = RD_SUCCESS;
# if RB_BUTTON_PWR_PIN_NUMBER
ri_gpio_id_t button_pwr_pins[RB_BUTTON_PWR_PIN_NUMBER] = RB_BUTTON_PWR_PINS;

for (size_t ii = 0; ii < RB_BUTTON_PWR_PIN_NUMBER; ii++)
{
err_code |= ri_gpio_configure (button_pwr_pins[ii],
RI_GPIO_MODE_OUTPUT_HIGHDRIVE);
err_code |= ri_gpio_write (button_pwr_pins[ii], RI_GPIO_HIGH);
}

# endif
err_code |= rt_button_init (&m_init_data);
return err_code;
}

#else
rd_status_t app_button_init (void)
{
return RD_SUCCESS;
}
#endif

/*@}*/
51 changes: 51 additions & 0 deletions src/app_button.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#ifndef APP_BUTTON_H
#define APP_BUTTON_H

#include "app_config.h"
#include "ruuvi_boards.h"
#include "ruuvi_driver_error.h"
#include "ruuvi_task_button.h"
#include "ruuvi_task_gpio.h"

/**
* @addtogroup app
*/
/*@{*/
/**
* @defgroup app_button Button, HALL etc support.
* @brief Actions when button, hall etc are activated.
*
*/
/*@}*/
/**
* @addtogroup app_button
*/
/*@{*/
/**
* @file app_button.h
* @author Otso Jousimaa <[email protected]>
* @date 2020-02-12
* @copyright Ruuvi Innovations Ltd, license BSD-3-Clause.
*/

/**
* @brief Initialize buttons.
*
* After initialization buttons are powered if needed and
* the callback defined at app_button.c is called on activation.
*
* @retval RD_SUCCESS if buttons were initialized
* @retval RD_ERROR_INVALID_STATE if RI_GPIO or RI_GPIO_INTERRUPT are not initialized.
*/
rd_status_t app_button_init (void);

#ifdef CEEDLING
void on_button_1_press (const ri_gpio_evt_t evt);
void on_button_2_press (const ri_gpio_evt_t evt);
void on_button_3_press (const ri_gpio_evt_t evt);
void on_button_4_press (const ri_gpio_evt_t evt);
ri_gpio_slope_t get_activation (ri_gpio_evt_t evt);
#endif
/*@}*/

#endif // APP_BUTTON_H
Loading

0 comments on commit 7a9da7c

Please sign in to comment.