Skip to content

Commit

Permalink
#374 update dir structs for x86
Browse files Browse the repository at this point in the history
  • Loading branch information
jcecconi committed Jan 14, 2016
1 parent e620e17 commit 75aad8d
Show file tree
Hide file tree
Showing 5 changed files with 399 additions and 5 deletions.
144 changes: 144 additions & 0 deletions modules/hisio/gen/inc/x86/Dio_Cfg_Arch.h.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/********************************************************
* DO NOT CHANGE THIS FILE, IT IS GENERATED AUTOMATICALY*
********************************************************/

/* Copyright 2015, Mariano Cerdeiro
* Copyright 2016, Juan Cecconi
* All rights reserved.
*
* This file is part of CIAA Firmware.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/

#ifndef DIO_CFG_ARCH_H
#define DIO_CFG_ARCH_H
/** \brief DIO Driver Configuration File Arch
**
** This file contains the DIO Driver configuration Arch
**
**/

/** \addtogroup CIAA_Firmware CIAA Firmware
** @{ */
/** \addtogroup HISIO HisIO Module
** @{ */

/*
* Initials Name
* ---------------------------
* MaCe Mariano Cerdeiro
* JuCe Juan Cecconi
*/

/*
* modification history (new versions first)
* -----------------------------------------------------------
* 20151222 v0.0.1 MaCe initial version
*/

/*==================[inclusions]=============================================*/
#include "ciaaPOSIX_stdint.h"

/*==================[cplusplus]==============================================*/
#ifdef __cplusplus
extern "C" {
#endif

/*==================[macros]=================================================*/

<?php
$dios = $config->getList("/DIL", "DIO");
foreach ($dios as $count=>$dio) {
if ($count != 0) {
$this->error("Maximal one configuration is supported.");
}
?>
/** \brief DIO Configuration pointer
**
** \remarks At the moment only one configuration is supported, so the
** parameter is set to null pointer.
**
**/
<?php
$pins = $config->getList("/DIL/" . $dio, "PIN");

foreach($pins as $count=>$pin) {
$pin_port = $config->getValue("/DIL/" . $dio . "/" . $pin, "PORT");
$pin_pin = $config->getValue("/DIL/" . $dio . "/" . $pin, "PIN");
print "/** \brief Port: " . $pin_port . " Pin: " . $pin_pin . " called " . $pin . " */\n";
print "#define " . $pin . " " . $count . "\n";
}
print "\n";
print "/** \brief Dio Pins count */\n";
print "#define DIO_PINS_COUNT " . count($pins) . "U\n\n";

$ports = $config->getList("/DIL/" . $dio, "PORT");

foreach($ports as $count=>$port) {
$port_port = $config->getValue("/DIL/" . $dio . "/" . $port, "PORT");
print "/** \brief Port: " . $port_port. " called " . $port . " */\n";
print "#define " . $port . " " . $count . "\n";
}
}
?>

/*==================[typedef]================================================*/
typedef struct {
uint8_t Port;
uint8_t Pin;
uint32_t Flags; /* Inverted, Direction, I/O, etc */
} Dio_PinConfigType;

typedef struct {
Dio_PinConfigType Pins[DIO_PINS_COUNT];
uint8_t foo;
} Dio_ConfigType;

/*==================[external data declaration]==============================*/
/** \brief Dio Config struct
**
** Contents the Dio Config settings
**/
<?php
foreach ($dios as $count=>$dio) {
print "/** \brief Configration of Dio Driver: " . $dio . " */\n";
print "extern const Dio_ConfigType Dio_Config;\n";
}
?>

/*==================[external functions declaration]=========================*/

/*==================[cplusplus]==============================================*/
#ifdef __cplusplus
}
#endif
/** @} doxygen end group definition */
/** @} doxygen end group definition */
/*==================[end of file]============================================*/
#endif /* #ifndef DIO_CFG_ARCH_H */
140 changes: 140 additions & 0 deletions modules/hisio/gen/src/x86/Dio_Cfg_Arch.c.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/********************************************************
* DO NOT CHANGE THIS FILE, IT IS GENERATED AUTOMATICALY*
********************************************************/

/* Copyright 2016, Juan Cecconi
* All rights reserved.
*
* This file is part of CIAA Firmware.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/

/** \brief DIO Driver Configuration File
**
** This file contains the DIO Driver configuration
**
**/

/** \addtogroup CIAA_Firmware CIAA Firmware
** @{ */
/** \addtogroup HISIO HisIO Module
** @{ */

/*
* Initials Name
* ---------------------------
* JuCe Juan Cecconi
*/

/*
* modification history (new versions first)
* -----------------------------------------------------------
* 20160110 v0.0.1 JuCe initial version
*/

/*==================[inclusions]=============================================*/
#include "Dio_Cfg.h"
#include "Dio_Cfg_Arch.h"

/*==================[macros and definitions]=================================*/

/*==================[internal data declaration]==============================*/

/*==================[internal functions declaration]=========================*/

/*==================[internal data definition]===============================*/

/*==================[external data declaration]==============================*/

/*==================[external data definition]==============================*/

<?php

/*
require_once './modules/hisio/gen/helpers/x86/hisio.php';
$MyHisio = new Hisio;
*/

$dios = $config->getList("/DIL", "DIO");
foreach ($dios as $count=>$dio) {
if ($count != 0) {
$this->log->error("Maximal one configuration is supported.");
}
$pins = $config->getList("/DIL/" . $dio, "PIN");

print "const Dio_ConfigType Dio_Config = {\n";
print "{\n";
foreach($pins as $count=>$pin) {
$pin_port = $config->getValue("/DIL/" . $dio . "/" . $pin, "PORT");
$pin_pin = $config->getValue("/DIL/" . $dio . "/" . $pin, "PIN");

$pin_direction = $config->getValue("/DIL/" . $dio . "/" . $pin, "DIRECTION");
switch ($pin_direction)
{
case "OUTPUT_INIT_LOW":
$pin_flags = "DIO_CONFIG_PIN_DIRECTION_OUTPUT_INIT_LOW";
break;
case "OUTPUT_INIT_HIGH":
$pin_flags = "DIO_CONFIG_PIN_DIRECTION_OUTPUT_INIT_HIGH";
break;
default:
$this->log->error("The pin $pin hasn't a defined direction!");
break;
}
$pin_inverted = $config->getValue("/DIL/" . $dio . "/" . $pin, "INVERTED");
switch ($pin_inverted)
{
case "TRUE":
$pin_flags = $pin_flags . " | DIO_CONFIG_PIN_INVERTED";
break;
case "FALSE":
break;
default:
$this->log->error("The pin $pin hasn't a defined 'inverted' configuration!");
break;
}
print "/** \brief Port: " . $pin_port . " Pin: " . $pin_pin . " called " . $pin . " */\n";
print "{ " . $pin_port . ", " . $pin_pin . ", (" . $pin_flags . ")},\n";
}
print "}\n";
print ", 0 /* foo var */\n";
print "};\n";
}
?>

/*==================[external functions declaration]=========================*/

/*==================[internal functions definition]==========================*/

/*==================[external functions definition]==========================*/

/** @} doxygen end group definition */
/** @} doxygen end group definition */
/*==================[end of file]============================================*/

9 changes: 6 additions & 3 deletions modules/hisio/mak/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ hisio_INC_PATH = $(hisio_PATH)$(DS)inc
$(hisio_PATH)$(DS)inc$(DS)$(ARCH)$(DS)$(CPUTYPE) \
$(hisio_PATH)$(DS)inc$(DS)$(ARCH)$(DS)$(CPUTYPE)$(DS)$(CPU) \
$(GEN_DIR)$(DS)inc \
$(GEN_DIR)$(DS)inc$(DS)$(ARCH) \
$(GEN_DIR)$(DS)inc$(DS)$(ARCH)$(DS)$(CPUTYPE)$(DS)$(CPU)

# library source files
Expand All @@ -58,6 +59,8 @@ hisio_SRC_FILES = $(wildcard $(hisio_SRC_PATH)$(DS)*.c)

# files to be generated
# TODO see https://github.com/ciaa/Firmware/issues/277
rtos_GEN_FILES += $(hisio_PATH)$(DS)gen$(DS)inc$(DS)IODriver_Cfg.h.php \
$(hisio_PATH)$(DS)gen$(DS)inc$(DS)$(ARCH)$(DS)$(CPUTYPE)$(DS)$(CPU)$(DS)Dio_Cfg_Arch.h.php \
$(hisio_PATH)$(DS)gen$(DS)src$(DS)$(ARCH)$(DS)$(CPUTYPE)$(DS)$(CPU)$(DS)Dio_Cfg_Arch.c.php
rtos_GEN_FILES += $(wildcard $(hisio_PATH)$(DS)gen$(DS)inc$(DS)*.php) \
$(wildcard $(hisio_PATH)$(DS)gen$(DS)inc$(DS)$(ARCH)$(DS)*.php) \
$(wildcard $(hisio_PATH)$(DS)gen$(DS)src$(DS)$(ARCH)$(DS)*.php) \
$(wildcard $(hisio_PATH)$(DS)gen$(DS)inc$(DS)$(ARCH)$(DS)$(CPUTYPE)$(DS)$(CPU)$(DS)*.php) \
$(wildcard $(hisio_PATH)$(DS)gen$(DS)src$(DS)$(ARCH)$(DS)$(CPUTYPE)$(DS)$(CPU)$(DS)*.php)
3 changes: 1 addition & 2 deletions modules/hisio/src/cortexM4/lpc43xx/lpc4337/Dio_Arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

/** \brief IO DIO Driver Arch source file
**
** This file contains is the Dio driver Arch
** This file contains is the Dio driver Arch CortexM4\lpc43xx\lpc4337
**
**/

Expand Down Expand Up @@ -149,4 +149,3 @@ extern void Dio_SetPortMaskedSync_Arch(IO_ChannelType channel, IO_ValueType valu
/** @} doxygen end group definition */
/** @} doxygen end group definition */
/*==================[end of file]============================================*/

Loading

0 comments on commit 75aad8d

Please sign in to comment.