Skip to content

Commit

Permalink
spled framework
Browse files Browse the repository at this point in the history
  • Loading branch information
cuinixam authored and xxthunder committed Sep 28, 2023
1 parent 60f6e20 commit 5ae17ae
Show file tree
Hide file tree
Showing 25 changed files with 201 additions and 12 deletions.
11 changes: 10 additions & 1 deletion .vscode/cmake-variants.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,17 @@
"SUBSYSTEM": "gamma"
},
"short": "spl/gamma"
},
"spl/disco": {
"buildType": "spl_disco",
"long": "select to build variant 'spl/disco'",
"settings": {
"FLAVOR": "spl",
"SUBSYSTEM": "disco"
},
"short": "spl/disco"
}
},
"default": "alpha"
"default": "disco"
}
}
2 changes: 2 additions & 0 deletions src/console_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
spl_add_source(src/console_interface.c)
spl_create_component()
5 changes: 5 additions & 0 deletions src/console_interface/src/console_interface.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "console_interface.h"

void consoleInterface(void) {

}
8 changes: 8 additions & 0 deletions src/console_interface/src/console_interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef __console_interface_h__
#define __console_interface_h__

#include "rte.h"

void consoleInterface(void);

#endif // __console_interface_h__
2 changes: 2 additions & 0 deletions src/keyboard_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
spl_add_source(src/keyboard_interface.c)
spl_create_component()
14 changes: 14 additions & 0 deletions src/keyboard_interface/src/keyboard_interface.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "keyboard_interface.h"
#include <windows.h>

boolean isKeyPressed(int key) {
if (GetAsyncKeyState(key)) {
return TRUE;
} else {
return FALSE;
}
}

void keyboardInterface(){

}
8 changes: 8 additions & 0 deletions src/keyboard_interface/src/keyboard_interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef __keyboard_interface_h__
#define __keyboard_interface_h__

#include "rte.h"

void keyboardInterface();

#endif // __keyboard_interface_h__
2 changes: 2 additions & 0 deletions src/light_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
spl_add_source(src/light_controller.c)
spl_create_component()
6 changes: 6 additions & 0 deletions src/light_controller/src/light_controller.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "light_controller.h"
#include "Rte.h"

void lightController(void) {

}
6 changes: 6 additions & 0 deletions src/light_controller/src/light_controller.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __light_controller_h__
#define __light_controller_h__

void lightController(void);

#endif // __light_controller_h__
2 changes: 1 addition & 1 deletion src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include(parts.cmake)
spl_add_source(src/main.c)
spl_create_component()
1 change: 0 additions & 1 deletion src/main/parts.cmake

This file was deleted.

16 changes: 7 additions & 9 deletions src/main/src/main.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#include "autoconf.h"

#if CONFIG_DUMMY_INTERFACE_DEFINED
#include "component.h"
extern int dummyInterface(void);
#endif
#include "spled.h"

int main(void) {
#if (CONFIG_DUMMY_INTERFACE_DEFINED)
return dummyInterface();
#else

while (1)
{
spled();
}

return 0;
#endif
}
2 changes: 2 additions & 0 deletions src/power_signal_processing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
spl_add_source(src/power_signal_processing.c)
spl_create_component()
7 changes: 7 additions & 0 deletions src/power_signal_processing/src/power_signal_processing.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "power_signal_processing.h"
#include "Rte.h"

// Function to check if "P" key was pressed and toggle power accordingly
void powerSignalProcessing(void) {

}
6 changes: 6 additions & 0 deletions src/power_signal_processing/src/power_signal_processing.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __power_signal_processing_h__
#define __power_signal_processing_h__

void powerSignalProcessing(void);

#endif // __power_signal_processing_h__
2 changes: 2 additions & 0 deletions src/rte/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
spl_add_source(src/rte.c)
spl_create_component()
30 changes: 30 additions & 0 deletions src/rte/src/rte.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "rte.h"

// Internal variable to hold the power state
static PowerState currentPowerState = POWER_STATE_OFF;
static boolean powerKeyPressed = FALSE;
static int lightValue = 0;

void RteSetPowerState(PowerState state) {
currentPowerState = state;
}

PowerState RteGetPowerState(void) {
return currentPowerState;
}

void RteSetPowerKeyPressed(boolean value) {
powerKeyPressed = value;
}

boolean RteGetPowerKeyPressed() {
return powerKeyPressed;
}

void RteSetLightValue(int value) {
lightValue = value;
}

int RteGetLightValue(void) {
return lightValue;
}
24 changes: 24 additions & 0 deletions src/rte/src/rte.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef __rte_h__
#define __rte_h__

// Define type for boolean
typedef unsigned char boolean;
#define TRUE 1
#define FALSE 0

// Define the PowerState type
typedef enum {
POWER_STATE_OFF = 0,
POWER_STATE_ON = 1
} PowerState;

void RteSetPowerState(PowerState state);
PowerState RteGetPowerState(void);

boolean RteGetPowerKeyPressed();
void RteSetPowerKeyPressed(boolean value);

void RteSetLightValue(int value);
int RteGetLightValue(void);

#endif // __rte_h__
2 changes: 2 additions & 0 deletions src/spled/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
spl_add_source(src/spled.c)
spl_create_component()
15 changes: 15 additions & 0 deletions src/spled/src/spled.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <stdio.h>

#include "spled.h"

#include "keyboard_interface.h"
#include "power_signal_processing.h"
#include "light_controller.h"
#include "console_interface.h"

void spled(void) {
keyboardInterface();
powerSignalProcessing();
lightController();
consoleInterface();
}
6 changes: 6 additions & 0 deletions src/spled/src/spled.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __spled_h__
#define __spled_h__

void spled(void);

#endif // __spled_h__
1 change: 1 addition & 0 deletions variants/spl/disco/config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(CMAKE_TOOLCHAIN_FILE tools/toolchains/gcc/toolchain.cmake CACHE PATH "toolchain file")
28 changes: 28 additions & 0 deletions variants/spl/disco/config.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

#
# SPL Extensions
#

#
# ZIP extension
#
CONFIG_ZIP_FEATURE=n
CONFIG_ZIP_TOOL_VERSION="1.0.2"
# end of ZIP extension
# end of SPL Extensions

#
# Linking
#
CONFIG_LINKER_OUTPUT_FILE="my_main.exe"
CONFIG_LINKER_BYPRODUCTS_EXTENSIONS="map"
# end of Linking

#
# Feature Model
#
CONFIG_USE_COMPONENT_A_INTERFACE=y
# CONFIG_USE_COMPONENT_B_INTERFACE is not set
CONFIG_DUMMY_INTERFACE_DEFINED=y
CONFIG_PART_NUMBER="PN0013"
# end of Feature Model
7 changes: 7 additions & 0 deletions variants/spl/disco/parts.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
spl_add_component(src/main)
spl_add_component(src/rte)
spl_add_component(src/spled)
spl_add_component(src/power_signal_processing)
spl_add_component(src/light_controller)
spl_add_component(src/keyboard_interface)
spl_add_component(src/console_interface)

0 comments on commit 5ae17ae

Please sign in to comment.