Skip to content

Commit

Permalink
adding roughly scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
roycohen2013 committed Aug 22, 2015
1 parent a1523b0 commit 6269ea4
Show file tree
Hide file tree
Showing 15 changed files with 160 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,4 @@ $RECYCLE.BIN/
!/Firmware/Tiva/driverlib/ccs/Debug
Firmware/projects/BareEthernet/.launches/BareEthernet.launch
Firmware/projects/BareEthernet/.launches/BareEthernet.launch
Firmware/projects/BareEthernet/.launches/BareEthernet.launch
2 changes: 2 additions & 0 deletions Firmware/Tiva/utils/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include "driverlib/debug.h"
#include "utils/scheduler.h"



//*****************************************************************************
//
//! \addtogroup scheduler_api
Expand Down
34 changes: 17 additions & 17 deletions Firmware/projects/BareEthernet/.launches/BareEthernet.launch
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.ti.ccstudio.debug.launchType.device.debugging">
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_CPUS_WITH_PROJECT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;cpus_with_project&gt;&#13;&#10;&lt;id id=&quot;Stellaris In-Circuit Debug Interface/CORTEX_M4_0&quot; isa=&quot;CORTEX_M4&quot;/&gt;&#13;&#10;&lt;/cpus_with_project&gt;"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.Stellaris In-Circuit Debug Interface/CORTEX_M4_0" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot; ?&gt;&#10;&lt;PropertyValues&gt;&#10;&#10; &lt;property id=&quot;ConnectOnStartup&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;EnableInstalledBreakpoint&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;IgnoreSoftLaunchFailures&quot;&gt;&#10; &lt;curValue&gt;0&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10;&lt;/PropertyValues&gt;&#10;"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.Stellaris In-Circuit Debug Interface/CORTEX_M4_0" value="${build_artifact:BareEthernet}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.Stellaris In-Circuit Debug Interface/CORTEX_M4_0" value="BareEthernet"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_TARGET_CONFIG" value="${target_config_active_default:BareEthernet}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.Stellaris In-Circuit Debug Interface/CORTEX_M4_0" value="C:/Users\Billy\Documents\GitHub\RITLaunchInitiative\Firmware\projects\BareEthernet\Debug\BareEthernet.out"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/BareEthernet"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="com.ti.ccstudio.debug.sourceLocator"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;sourceLookupDirector&gt;&#13;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;default/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;cpuSpecificContainer cpuName=&amp;quot;Stellaris In-Circuit Debug Interface/CORTEX_M4_0&amp;quot;&amp;gt;&amp;#13;&amp;#10;&amp;lt;childContainerEntry childMemento=&amp;quot;&amp;amp;lt;?xml version=&amp;amp;quot;1.0&amp;amp;quot; encoding=&amp;amp;quot;UTF-8&amp;amp;quot; standalone=&amp;amp;quot;no&amp;amp;quot;?&amp;amp;gt;&amp;amp;#13;&amp;amp;#10;&amp;amp;lt;default/&amp;amp;gt;&amp;amp;#13;&amp;amp;#10;&amp;quot; childType=&amp;quot;org.eclipse.debug.core.containerType.default&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&amp;lt;childContainerEntry childMemento=&amp;quot;&amp;amp;lt;?xml version=&amp;amp;quot;1.0&amp;amp;quot; encoding=&amp;amp;quot;UTF-8&amp;amp;quot; standalone=&amp;amp;quot;no&amp;amp;quot;?&amp;amp;gt;&amp;amp;#13;&amp;amp;#10;&amp;amp;lt;project name=&amp;amp;quot;BareEthernet&amp;amp;quot; referencedProjects=&amp;amp;quot;true&amp;amp;quot;/&amp;amp;gt;&amp;amp;#13;&amp;amp;#10;&amp;quot; childType=&amp;quot;org.eclipse.debug.core.containerType.project&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&amp;lt;/cpuSpecificContainer&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;com.ti.ccstudio.debug.containerType.cpu.specific&quot;/&gt;&#13;&#10;&lt;/sourceContainers&gt;&#13;&#10;&lt;/sourceLookupDirector&gt;&#13;&#10;"/>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.ti.ccstudio.debug.launchType.device.debugging">
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_CPUS_WITH_PROJECT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#13;&#10;&lt;cpus_with_project&gt;&#13;&#10;&lt;id id=&quot;Stellaris In-Circuit Debug Interface/CORTEX_M4_0&quot; isa=&quot;CORTEX_M4&quot;/&gt;&#13;&#10;&lt;/cpus_with_project&gt;"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_DEBUGGER_PROPERTIES.Stellaris In-Circuit Debug Interface/CORTEX_M4_0" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot; ?&gt;&#10;&lt;PropertyValues&gt;&#10;&#10; &lt;property id=&quot;ConnectOnStartup&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;EnableInstalledBreakpoint&quot;&gt;&#10; &lt;curValue&gt;1&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10; &lt;property id=&quot;IgnoreSoftLaunchFailures&quot;&gt;&#10; &lt;curValue&gt;0&lt;/curValue&gt;&#10; &lt;/property&gt;&#10;&#10;&lt;/PropertyValues&gt;&#10;"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROGRAM.Stellaris In-Circuit Debug Interface/CORTEX_M4_0" value="${build_artifact:BareEthernet}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_PROJECT.Stellaris In-Circuit Debug Interface/CORTEX_M4_0" value="BareEthernet"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.ATTR_TARGET_CONFIG" value="${target_config_active_default:BareEthernet}"/>
<stringAttribute key="com.ti.ccstudio.debug.debugModel.MRU_PROGRAM.Stellaris In-Circuit Debug Interface/CORTEX_M4_0" value="C:/Users\Billy\Documents\GitHub\RITLaunchInitiative\Firmware\projects\BareEthernet\Debug\BareEthernet.out"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/BareEthernet"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="com.ti.ccstudio.debug.sourceLocator"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;sourceLookupDirector&gt;&#13;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;default/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;cpuSpecificContainer cpuName=&amp;quot;Stellaris In-Circuit Debug Interface/CORTEX_M4_0&amp;quot;&amp;gt;&amp;#13;&amp;#10;&amp;lt;childContainerEntry childMemento=&amp;quot;&amp;amp;lt;?xml version=&amp;amp;quot;1.0&amp;amp;quot; encoding=&amp;amp;quot;UTF-8&amp;amp;quot; standalone=&amp;amp;quot;no&amp;amp;quot;?&amp;amp;gt;&amp;amp;#13;&amp;amp;#10;&amp;amp;lt;default/&amp;amp;gt;&amp;amp;#13;&amp;amp;#10;&amp;quot; childType=&amp;quot;org.eclipse.debug.core.containerType.default&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&amp;lt;childContainerEntry childMemento=&amp;quot;&amp;amp;lt;?xml version=&amp;amp;quot;1.0&amp;amp;quot; encoding=&amp;amp;quot;UTF-8&amp;amp;quot; standalone=&amp;amp;quot;no&amp;amp;quot;?&amp;amp;gt;&amp;amp;#13;&amp;amp;#10;&amp;amp;lt;project name=&amp;amp;quot;BareEthernet&amp;amp;quot; referencedProjects=&amp;amp;quot;true&amp;amp;quot;/&amp;amp;gt;&amp;amp;#13;&amp;amp;#10;&amp;quot; childType=&amp;quot;org.eclipse.debug.core.containerType.project&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&amp;lt;/cpuSpecificContainer&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;com.ti.ccstudio.debug.containerType.cpu.specific&quot;/&gt;&#13;&#10;&lt;/sourceContainers&gt;&#13;&#10;&lt;/sourceLookupDirector&gt;&#13;&#10;"/>
</launchConfiguration>
1 change: 1 addition & 0 deletions Firmware/projects/HybridEngineControl/.ccsproject
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
<rts value="libc.a"/>
<createSlaveProjects value=""/>
<templateProperties value="id=com.ti.common.project.core.emptyProjectWithMainTemplate,"/>
<isTargetManual value="false"/>
</projectOptions>
1 change: 1 addition & 0 deletions Firmware/projects/HybridEngineControl/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<option id="com.ti.ccstudio.buildDefinitions.TMS470_5.2.compilerID.INCLUDE_PATH.1372601477" name="Add dir to #include search path (--include_path, -I)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_5.2.compilerID.INCLUDE_PATH" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${CG_TOOL_ROOT}/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${LAUNCH_LOCATION}\Firmware\Tiva&quot;"/>
<listOptionValue builtIn="false" value="&quot;C:\ti\TivaWare_C_Series-2.1.0.12573\utils&quot;"/>
</option>
<option id="com.ti.ccstudio.buildDefinitions.TMS470_5.2.compilerID.LITTLE_ENDIAN.1568907413" name="Little endian code [See 'General' page to edit] (--little_endian, -me)" superClass="com.ti.ccstudio.buildDefinitions.TMS470_5.2.compilerID.LITTLE_ENDIAN" value="true" valueType="boolean"/>
<inputType id="com.ti.ccstudio.buildDefinitions.TMS470_5.2.compiler.inputType__C_SRCS.1164690251" name="C Sources" superClass="com.ti.ccstudio.buildDefinitions.TMS470_5.2.compiler.inputType__C_SRCS"/>
Expand Down
10 changes: 10 additions & 0 deletions Firmware/projects/HybridEngineControl/.project
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,15 @@
<type>1</type>
<locationURI>LAUNCH_LOCATION/Firmware/Tiva/driverlib/ccs/Debug/driverlib.lib</locationURI>
</link>
<link>
<name>scheduler.c</name>
<type>1</type>
<locationURI>LAUNCH_LOCATION/Firmware/Tiva/utils/scheduler.c</locationURI>
</link>
<link>
<name>scheduler.h</name>
<type>1</type>
<locationURI>LAUNCH_LOCATION/Firmware/Tiva/utils/scheduler.h</locationURI>
</link>
</linkedResources>
</projectDescription>
33 changes: 31 additions & 2 deletions Firmware/projects/HybridEngineControl/led_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,24 @@

#define NUM_LEDS 4


uint8_t ledTaskNum;

ledUnit_t statusLeds[NUM_LEDS];
uint32_t ledManagerPeriod;


//tSchedulerTask ledTaskInit(uint8_t taskNumber){
//
// ledTaskNum = taskNumber;
// tSchedulerTask ledTask;
//
// ledTask
//
//
//}


void ledManagerInit(uint32_t period) {

ledManagerPeriod = period;
Expand Down Expand Up @@ -137,7 +152,7 @@ void blink_all_leds(uint16_t period){

uint8_t i;
for (i = 0; i < NUM_LEDS; ++i) {
blink_led(i, period)
blink_led(i, period);
}

}
Expand All @@ -158,8 +173,12 @@ void turnOffLed(uint8_t index) {
}


void ledTaskHandler(void *pvParam){

void ledManagerHandler() {
ledManagerHandler();
}

void ledManagerHandler(void) {

uint8_t i;
for (i = 0; i < NUM_LEDS; ++i) {
Expand Down Expand Up @@ -223,3 +242,13 @@ void ledManagerHandler() {
}
}


void Timer0IntHandler(void) {
// Clear the timer interrupt
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
// Read the current state of the GPIO pin and
// write back the opposite state
// Read the current state of the GPIO pin and
// write back the opposite state
ledManagerHandler();
}
25 changes: 14 additions & 11 deletions Firmware/projects/HybridEngineControl/led_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define LED_UTIL_H_


#include <stdint.h>
//#include <stdint.h>

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -107,19 +107,22 @@ typedef struct ledUnit_t
} ledUnit_t;


void ledManagerHandler(void);
void ledManagerInit(uint32_t);
void initLed(ledUnit_t *led, uint32_t port,uint32_t pin,bool invert);
void Timer0IntHandler(void);

extern void ledTaskHandler(void *pvParam);
extern void ledManagerHandler(void);
extern void ledManagerInit(uint32_t);
extern void initLed(ledUnit_t *led, uint32_t port,uint32_t pin,bool invert);


void stop_blinking(uint8_t);
void pulse_all_leds(uint16_t num_pulses);
void blink_all_leds(uint16_t period);
void pulse_led(uint8_t, uint16_t num_pulses, uint16_t period);
void blink_led(uint8_t, uint16_t period);
void lock_led(uint8_t);
void unlock_led(uint8_t);

extern void stop_blinking(uint8_t);
extern void pulse_all_leds(uint16_t num_pulses);
extern void blink_all_leds(uint16_t period);
extern void pulse_led(uint8_t, uint16_t num_pulses, uint16_t period);
extern void blink_led(uint8_t, uint16_t period);
extern void lock_led(uint8_t);
extern void unlock_led(uint8_t);



Expand Down
92 changes: 76 additions & 16 deletions Firmware/projects/HybridEngineControl/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,66 @@
#include "driverlib/interrupt.h"
#include "driverlib/timer.h"

#include "utils/scheduler.h"
#include "led_util.h"

uint8_t ui8PinData = 1;


//uint8_t ui8PinData = 1;

//*****************************************************************************
//
// Definition of the system tick rate. This results in a tick period of 10mS.
//
//*****************************************************************************
#define TICKS_PER_SECOND 10000



//*****************************************************************************
//
// Prototypes of functions which will be called by the scheduler.
//
//*****************************************************************************
//static void ScrollTextBanner(void *pvParam);
//static void ToggleLED(void *pvParam);
//*****************************************************************************
//
// This table defines all the tasks that the scheduler is to run, the periods
// between calls to those tasks, and the parameter to pass to the task.
//
//*****************************************************************************
tSchedulerTask g_psSchedulerTable[] = {
//
// Scroll the text banner 1 character to the left. This function is called
// every 20 ticks (5 times per second).
//
{ ledTaskHandler, (void *) 0, 100, 0, true }
//
// Toggle LED number 0 every 50 ticks (twice per second).
//
//{ ToggleLED, (void *) 0, 50, 0, true },
//
// Toggle LED number 1 every 100 ticks (once per second).
//
//{ ToggleLED, (void *) 1, 100, 0, true },

};


//*****************************************************************************
//
// The number of entries in the global scheduler task table.
//
//*****************************************************************************
unsigned long g_ulSchedulerNumTasks = (sizeof(g_psSchedulerTable)
/ sizeof(tSchedulerTask));

uint32_t g_ui32SchedulerNumTasks = 1;





int main(void) {

Expand All @@ -29,27 +86,40 @@ int main(void) {
SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);


SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);



//GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0|GPIO_PIN_1);

INIT_LED_MANAGER(0, 1000); //Selects the proper timer and sets the period
//INIT_LED_MANAGER(0, 1000); //Selects the proper timer and sets the period
ledManagerInit(1000);





//
// Initialize the task scheduler and configure the SysTick to interrupt
// 100 times per second.
//
SchedulerInit(TICKS_PER_SECOND);





//ledUnit_t StatusLed1;
//ledUnit_t StatusLed2;

pulse_all_leds(5);

while (1) {

pulse_all_leds(5);

SchedulerRun();


while (1) {
// GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0 | GPIO_PIN_1, 0xFF);
// GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, 0xFF);
// SysCtlDelay(2000000);
Expand All @@ -66,16 +136,6 @@ int main(void) {
}
//gpio_t Solinoid_1;


return 0;
}

void Timer0IntHandler(void) {
// Clear the timer interrupt
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
// Read the current state of the GPIO pin and
// write back the opposite state
// Read the current state of the GPIO pin and
// write back the opposite state
ledManagerHandler();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <stdint.h>

//#include "utils/scheduler.h"
//*****************************************************************************
//
// Forward declaration of the default fault handlers.
Expand All @@ -42,6 +43,7 @@ static void IntDefaultHandler(void);
//*****************************************************************************
extern void _c_int00(void);
extern void Timer0IntHandler(void);
extern void SchedulerSysTickIntHandler(void);
//*****************************************************************************
//
// Linker variable that marks the top of the stack.
Expand Down Expand Up @@ -82,7 +84,7 @@ void (* const g_pfnVectors[])(void) =
IntDefaultHandler, // Debug monitor handler
0, // Reserved
IntDefaultHandler, // The PendSV handler
IntDefaultHandler, // The SysTick handler
SchedulerSysTickIntHandler, // The SysTick handler
IntDefaultHandler, // GPIO Port A
IntDefaultHandler, // GPIO Port B
IntDefaultHandler, // GPIO Port C
Expand All @@ -102,7 +104,7 @@ void (* const g_pfnVectors[])(void) =
IntDefaultHandler, // ADC Sequence 2
IntDefaultHandler, // ADC Sequence 3
IntDefaultHandler, // Watchdog timer
Timer0IntHandler, // Timer 0 subtimer A
IntDefaultHandler, // Timer 0 subtimer A
IntDefaultHandler, // Timer 0 subtimer B
IntDefaultHandler, // Timer 1 subtimer A
IntDefaultHandler, // Timer 1 subtimer B
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://training.ti.com/tm4c129x-mcus-series-part-3-guidelines-ethernet -- TI Ethernet routing guidelines
http://www.eetimes.com/document.asp?doc_id=1277940 -- bob smith termination

Binary file not shown.
Binary file not shown.

0 comments on commit 6269ea4

Please sign in to comment.