Skip to content

Commit

Permalink
#374 add Dio PORT config on php files
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanManuelCruz committed Jan 22, 2016
1 parent f6e70ea commit abda71d
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
* ---------------------------
* MaCe Mariano Cerdeiro
* JuCe Juan Cecconi
* JMC Juan Manuel Cruz
*/

/*
Expand Down Expand Up @@ -82,6 +83,7 @@
$dios = $config->getList("/DIL", "DIO");
if(count($dios) == 0){
print "#define DIO_PINS_COUNT 0U\n\n";
print "#define DIO_PORTS_COUNT 0U\n\n";
}
else{
foreach ($dios as $count=>$dio) {
Expand All @@ -90,7 +92,7 @@
}
$pins = $config->getList("/DIL/" . $dio, "PIN");
print "#define DIO_PINS_COUNT " . count($pins) . "U\n\n";

foreach($pins as $count=>$pin) {
$pin_port = $config->getValue("/DIL/" . $dio . "/" . $pin, "PORT");
$pin_pin = $config->getValue("/DIL/" . $dio . "/" . $pin, "PIN");
Expand All @@ -99,9 +101,12 @@
}

$ports = $config->getList("/DIL/" . $dio, "PORT");
print "\n";
print "#define DIO_PORTS_COUNT " . count($ports) . "U\n\n";

foreach($ports as $count=>$port) {
$port_port = $config->getValue("/DIL/" . $dio . "/" . $port, "PORT");
$port_size = $config->getValue("/DIL/" . $dio . "/" . $port, "SIZE");
print "/** \brief Port: " . $port_port. " called " . $port . " */\n";
print "#define " . $port . " " . $count . "\n";
}
Expand All @@ -119,8 +124,16 @@
uint32_t Flags; /* Inverted, Direction, I/O, etc */
} Dio_PinConfigType;

typedef struct {
uint8_t Port;
uint8_t Size; /* 8, 16, 32 */
uint32_t Mask;
uint32_t Flags; /* Inverted, Direction, I/O, etc */
} Dio_PortConfigType;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
********************************************************/

/* Copyright 2016, Juan Cecconi
* Copyright 2016, Juan Manuel Cruz
* All rights reserved.
*
* This file is part of CIAA Firmware.
Expand Down Expand Up @@ -96,7 +97,7 @@
if ($GPIO == NULL) {
$this->log->error("PIN " . $pin . " has a 'Port-Pin' pair that doesn't match a valid GPIO.");
}
sscanf($GPIO, "GPIO%d[%d],FUNC%d", $GPIO_Port, $GPIO_Pin, $GPIO_Func);
sscanf($GPIO, "GPIO%d[%d], FUNC%d", $GPIO_Port, $GPIO_Pin, $GPIO_Func);

$pin_direction = $config->getValue("/DIL/" . $dio . "/" . $pin, "DIRECTION");
switch ($pin_direction)
Expand Down Expand Up @@ -129,7 +130,68 @@
print "/** \brief Port: " . $pin_port . " Pin: " . $pin_pin . " , " . $GPIO . " called " . $pin . " */\n";
print "{ 0x" . $pin_port . ", " . $pin_pin . ", 0x" . $GPIO_Port . ", " . $GPIO_Pin . ", SCU_MODE_FUNC" . $GPIO_Func . ", (" . $pin_flags . ")},\n";
}
print "},\n";

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

print "{\n";
foreach($ports as $count=>$port) {
$port_port = $config->getValue("/DIL/" . $dio . "/" . $port, "PORT");
$port_mask = $config->getValue("/DIL/" . $dio . "/" . $port, "MASK");

$port_size = $config->getValue("/DIL/" . $dio . "/" . $port, "SIZE");
switch ($port_size)
{
case "IO_PORT_SIZE_8":
$port_size = "8";
$port_flags = $port_flags . "DIO_CONFIG_PORT_SIZE_8";
break;
case "IO_PORT_SIZE_16":
$port_size = "16";
$port_flags = $port_flags . "DIO_CONFIG_PORT_SIZE_16";
break;
case "IO_PORT_SIZE_32":
$port_size = "32";
$port_flags = $port_flags . "DIO_CONFIG_PORT_SIZE_32";
break;
default:
$this->log->error("The port $port hasn't a defined size!");
break;
}
$port_direction = $config->getValue("/DIL/" . $dio . "/" . $port, "DIRECTION");
switch ($port_direction)
{
case "IO_INPUT":
$port_flags = " | DIO_CONFIG_PORT_DIRECTION_INPUT";
break;
case "IO_OUTPUT_INIT_LOW":
$port_flags = " | DIO_CONFIG_PORT_DIRECTION_OUTPUT_INIT_LOW";
break;
case "IO_OUTPUT_INIT_HIGH":
$port_flags = " | DIO_CONFIG_PORT_DIRECTION_OUTPUT_INIT_HIGH";
break;
default:
$this->log->error("The port $port hasn't a defined direction!");
break;
}
$port_inverted = $config->getValue("/DIL/" . $dio . "/" . $port, "INVERTED");
switch ($port_inverted)
{
case "TRUE":
$port_flags = $port_flags . " | DIO_CONFIG_PORT_INVERTED";
break;
case "FALSE":
break;
default:
$this->log->error("The port $port hasn't a defined 'inverted' configuration!");
break;
}
print "/** \brief Port: " . $port_port . " */\n";
print "{ " . $port_port . ", " . $port_size . ", 0x" . $port_mask . ", (" . $port_flags . ")},\n";

}
print "}\n";

print ", 0 /* foo var */\n";
print "};\n";
}
Expand Down
9 changes: 9 additions & 0 deletions modules/hisio/inc/Dio_Cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ extern "C" {
#define DIO_CONFIG_PIN_DIRECTION_OUTPUT_INIT_HIGH 0x00000008UL
#define DIO_CONFIG_PIN_INVERTED 0x00000010UL

#define DIO_CONFIG_PORT_DIRECTION_UNUSED 0x00000001UL
#define DIO_CONFIG_PORT_DIRECTION_INPUT 0x00000002UL
#define DIO_CONFIG_PORT_DIRECTION_OUTPUT_INIT_LOW 0x00000004UL
#define DIO_CONFIG_PORT_DIRECTION_OUTPUT_INIT_HIGH 0x00000008UL
#define DIO_CONFIG_PORT_INVERTED 0x00000010UL
#define DIO_CONFIG_PORT_SIZE_8 0x00000020UL
#define DIO_CONFIG_PORT_SIZE_16 0x00000040UL
#define DIO_CONFIG_PORT_SIZE_32 0x00000080UL

/*==================[typedef]================================================*/

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

0 comments on commit abda71d

Please sign in to comment.