Skip to content

Commit

Permalink
Cypress Wiced Platform Integration & Improvements (#2)
Browse files Browse the repository at this point in the history
*Added wiced-43xxx platform
*Added end() functionality
*Improved ~hallSwitch() destructor
*Updated metadata for 1.1.1 release
*Updated doxygen modules
*Updated .travis.yml for automatic doxygen gh-pages deployment
  • Loading branch information
jaenrig-ifx authored Jan 28, 2020
1 parent cef5f95 commit f09c443
Show file tree
Hide file tree
Showing 14 changed files with 508 additions and 50 deletions.
54 changes: 41 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,51 @@
os:
- linux

language: python

python:
- "2.7"
- 3.7

sudo: required

branches:
- master
- /^v.*$/

# Builds Test

env:
- PLATFORMIO_CI_SRC=examples/ardref-interrupt
- PLATFORMIO_CI_SRC=examples/ardref-polling
- PLATFORMIO_CI_SRC=examples/lib-interrupt
- PLATFORMIO_CI_SRC=examples/lib-polling

install:
- pip install -U platformio==4.1.0
- platformio platform install -f [email protected]
- platformio platform install -f [email protected]

script:
- platformio ci --lib="." --board=xmc1100_xmc2go --board=xmc1100_boot_kit --board=xmc4700_relax_kit --board=uno

jobs:
include:
- stage: "Deploy"
name: "GitHub Pages Deployment"
if: tag IS present
addons:
apt:
packages:
- doxygen
- graphviz
sources:
- ubuntu-toolchain-r-test
install:
- git clone https://github.com/Infineon/InfineonDoxyGenerator.git --branch v.0.2.1
script:
- cd InfineonDoxyGenerator
- python doxyifx.py html
- python doxyifx.py release $GH_USER $GH_PASS_TOKEN

env:
matrix:
- PLATFORMIO_CI_SRC=examples/ardref-interrupt
- PLATFORMIO_CI_SRC=examples/ardref-polling
- PLATFORMIO_CI_SRC=examples/lib-interrupt
- PLATFORMIO_CI_SRC=examples/lib-polling

install:
- pip install -U platformio
- platformio platform install -f infineonxmc
- platformio platform install -f atmelavr

script:
- platformio ci --lib="." --board=xmc1100_xmc2go --board=xmc1100_boot_kit --board=xmc4700_relax_kit --board=uno
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Infineon Technologies AG
Copyright (c) 2019-2020 Infineon Technologies AG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
25 changes: 14 additions & 11 deletions docs/doxygen/group_defs.dox
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@
* @{
*/

/** @defgroup hallswitchdatat Data Types */
/** @defgroup hallswitchcpphal API */
/** @defgroup hallswitchinohal Arduino API */
/** @defgroup hallswitchhwi Hardware Interfaces */
/** @defgroup hallswitchdatat Data Types */
/** @defgroup hallswitchcpphal API */
/** @defgroup hallswitchinohal Arduino API */
/** @defgroup hallswitchwicedhal WICED API */
/** @defgroup hallswitchhwi Hardware Interfaces */

/** @} */

/**
* @defgroup hallswitchhwp Hardware Platforms

/** @defgroup hallswitchpal PAL Frameworks
* @{
*/
/** @defgroup hallgpioino Arduino GPIO */
/** @defgroup hallgpiowiced WICED GPIO */
/** @} */

/** @defgroup hallhwino Arduino Hardware Platforms
/**
* @defgroup hallswitchhwp Hardware Platforms
* @{
*/
/** @defgroup hallgpioino Arduino GPIO */
/** @defgroup tle49643ms2go TLE4964-3M Shield2Go */

/** @defgroup tle49643ms2go TLE4964-3M Shield2Go */
/** @} */
/** @} */

8 changes: 7 additions & 1 deletion keyword.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#######################################

begin KEYWORD2
end KEYWORD2
enable KEYWORD2
disable KEYWORD2
getStatus KEYWORD2
Expand All @@ -30,4 +31,9 @@ HallSwitchIno KEYWORD2
#######################################

OK LITERAL1
UNINITED LITERAL1
INTF_ERROR LITERAL1
CONF_ERROR LITERAL1
UNINITED LITERAL1
INITED LITERAL1
POWER_ON LITERAL1
POWER_OFF LITERAL1
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url":"https://github.com/Infineon/hall-switch.git",
"branch":"master"
},
"version":"1.0.1",
"version":"1.1.1",
"license":"MIT",
"frameworks":"arduino",
"platforms":[
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=Hall-Switch
version=1.0.1
version=1.1.1
author=Infineon Technologies
maintainer=Infineon Technologies <www.infineon.com>
sentence=This library provides an interface to interact with the Hall effect sensor switch family
Expand Down
47 changes: 40 additions & 7 deletions src/hal/hall-switch.cpp → src/common/hall-switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ HallSwitch::HallSwitch(GPIO *output,
*/
HallSwitch::~HallSwitch()
{
disable();
if(status == POWER_ON)
disable();
if(status == POWER_OFF)
end();
}

/**
Expand Down Expand Up @@ -107,6 +110,35 @@ HallSwitch::Error_t HallSwitch::begin()
return err;
}

/**
* @brief Deinitializes the hardware interfaces
* @return HallSwitch error code
* @retval OK if success
* @retval INTF_ERROR if hardware interface error
*/
HallSwitch::Error_t HallSwitch::end()
{
Error_t err = OK;

if(powerMode == SWITCH)
{
if(power == NULL)
return INTF_ERROR;

INTF_ASSERT(power->deinit());
}

if(output == NULL)
return INTF_ERROR;

INTF_ASSERT(output->deinit());

status = UNINITED;
bfieldVal = B_FIELD_UNDEF;

return err;
}

/**
* @brief Enables the sensor
* - If "switch power mode " is configured, the sensor is powered up
Expand Down Expand Up @@ -232,7 +264,7 @@ void HallSwitch::callback()
/** @} */


HallSwitch* HallSwitch::Interrupt::objPtrVector[GPIO_ARD_INT_PINS] = {NULL};
HallSwitch* HallSwitch::Interrupt::objPtrVector[GPIO_INT_PINS] = {NULL};
uint8_t HallSwitch::Interrupt::idxNext = 0;

/**
Expand Down Expand Up @@ -267,14 +299,15 @@ void HallSwitch::Interrupt::int3Handler()
objPtrVector[3]->callback();
}

void* HallSwitch::Interrupt::fnPtrVector[GPIO_ARD_INT_PINS] = {int0Handler,
int1Handler,
int2Handler,
int3Handler};

void *HallSwitch::Interrupt::fnPtrVector[GPIO_INT_PINS] = {(void *)int0Handler,
(void *)int1Handler,
(void *)int2Handler,
(void *)int3Handler};

/**
* @brief Register a hardware interrupt on the argument hall switch object
* @param[in] *objPrt Hall switch object pointer
* @param[in] *objPtr Hall switch object pointer
* @return Pointer to allocated the interrupt function handler
*/
void *HallSwitch::Interrupt::isrRegister(HallSwitch *objPtr)
Expand Down
23 changes: 17 additions & 6 deletions src/hal/hall-switch.h → src/common/hall-switch.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class HallSwitch
GPIO *power = NULL);
~HallSwitch ();
HallSwitch::Error_t begin ();
HallSwitch::Error_t end ();
HallSwitch::Error_t enable ();
HallSwitch::Error_t disable ();
HallSwitch::Status_t getStatus ();
Expand Down Expand Up @@ -199,6 +200,14 @@ class HallSwitch::GPIO
*/
virtual Error_t init () = 0;

/**
* @brief Deinitializes the GPIO
* @return GPIO error code
* @retval OK if success
* @retval INIT_ERROR if deinitialization error
*/
virtual Error_t deinit () = 0;

/**
* @brief Enables the hardware interrupt
* @param[in] *ptr HallSwith object pointer which holds the interrupt
Expand All @@ -212,7 +221,7 @@ class HallSwitch::GPIO
* @brief Disables the hardware interrupt
* @return GPIO error code
* @retval OK if success
* @retval INIT_ERROR if deinitialization error
* @retval INIT_ERROR if disable error
*/
virtual Error_t disableInt () = 0;

Expand Down Expand Up @@ -260,6 +269,8 @@ class HallSwitch::GPIO
* @retval WRITE_ERROR if write error
*/
virtual Error_t disable () = 0;


};
/** @} */

Expand All @@ -273,10 +284,10 @@ class HallSwitch::GPIO
class HallSwitch::Interrupt
{
private:
#define GPIO_ARD_INT_PINS 4 /**< Maximum hardware interrupt signals */
static uint8_t idxNext; /**< Interrupt array allocation index*/
static HallSwitch *objPtrVector[GPIO_ARD_INT_PINS]; /**< Hall switch object pointers vector */
static void *fnPtrVector[GPIO_ARD_INT_PINS]; /**< Hall switch interrupt function handlers vector */
#define GPIO_INT_PINS 4 /**< Maximum hardware interrupt signals */
static uint8_t idxNext; /**< Interrupt array allocation index*/
static HallSwitch *objPtrVector[GPIO_INT_PINS]; /**< Hall switch object pointers vector */
static void *fnPtrVector[GPIO_INT_PINS]; /**< Hall switch interrupt function handlers vector */
static void int0Handler ();
static void int1Handler ();
static void int2Handler ();
Expand All @@ -287,4 +298,4 @@ class HallSwitch::Interrupt
/** @} */


#endif /** HALL_SWITCH_H_ **/
#endif /** HALL_SWITCH_H_ **/
4 changes: 2 additions & 2 deletions src/hall-switch-ino.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#define HALL_SWITCH_INO_H_

#include <Arduino.h>
#include "hal/hall-switch.h"
#include "hw-platf/hall-switch-platf-ard.h"
#include "common/hall-switch.h"
#include "pal/arduino/hall-switch-ard.h"

/**
* @class HallSwitchIno
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @file hall-switch-platf-ard.cpp
* @file hall-switch-ard.cpp
* @brief Hall Switch Arduino GPIO Hardware Interface
*
* Wraps the Arduino GPIO Reference Language calls
Expand All @@ -9,7 +9,7 @@
*/

#include <Arduino.h>
#include "hall-switch-platf-ard.h"
#include "hall-switch-ard.h"

/**
* @addtogroup hallgpioino
Expand Down Expand Up @@ -47,6 +47,16 @@ GPIOIno::Error_t GPIOIno::init()
return OK;
}

/**
* @brief Deinitializes the Arduino GPIO
* @return GPIO error code
* @retval OK always
*/
GPIOIno::Error_t GPIOIno::deinit()
{
return OK;
}

/**
* @brief Enables the Arduino GPIO interrupt
* @return GPIO error code
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/**
* @file hall-switch-platf-ard.h
* @file hall-switch-ard.h
* @brief Hall Switch Arduino GPIO Hardware Interface
* @date July 2019
* @copyright Copyright (c) 2019 Infineon Technologies AG
*/

#ifndef HALL_SWITCH_PLATF_ARD_H_
#define HALL_SWITCH_PLATF_ARD_H_
#ifndef HALL_SWITCH_ARD_H_
#define HALL_SWITCH_ARD_H_

#include <stdint.h>
#include "../hal/hall-switch.h"
#include "../../common/hall-switch.h"

class GPIOIno : virtual public HallSwitch::GPIO, public HallSwitch::Interrupt
{
Expand All @@ -25,6 +25,7 @@ class GPIOIno : virtual public HallSwitch::GPIO, public HallSwitch::Interrupt
uint8_t mode,
VLogic_t logic);
Error_t init ();
Error_t deinit ();
Error_t enableInt (HallSwitch *ptr);
Error_t disableInt ();
IntEvent_t intEvent ();
Expand All @@ -51,4 +52,4 @@ typedef struct
extern ArdHwPlatfPins_t TLE4964_3M_S2Go_Pins; /**< TLE4964 3M Shield 2Go Pins */
/** @} */

#endif /** HALL_SWITCH_PLATF_ARD_H_ **/
#endif /** HALL_SWITCH_ARD_H_ **/
Loading

0 comments on commit f09c443

Please sign in to comment.