Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tfang8 onboarding #56

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Firmware/project_1/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
<option id="com.crt.advproject.link.memory.load.image.cpp.1854760230" superClass="com.crt.advproject.link.memory.load.image.cpp" value="" valueType="string"/>
<option id="com.crt.advproject.link.memory.data.cpp.326173730" superClass="com.crt.advproject.link.memory.data.cpp" value="" valueType="string"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="com.crt.advproject.link.memory.sections.cpp.50157822" superClass="com.crt.advproject.link.memory.sections.cpp" valueType="stringList"/>
<option id="com.crt.advproject.link.cpp.multicore.master.1720075744" superClass="com.crt.advproject.link.cpp.multicore.master"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.2135286474" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
Expand Down Expand Up @@ -592,4 +593,5 @@
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.crt.advproject.GCCManagedMakePerProjectProfile"/>
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="openCmsis"/>
</cproject>
5 changes: 4 additions & 1 deletion Firmware/project_1/inc/pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#define P_LED2 P0_5
#define P_LED3 P0_6
#define P_LED4 P0_7
#define P_LED5 P0_4
#define P_POTENTIOMETER1 P0_3
// PROJECT 1 - You can define a pin macro here

/*
Expand All @@ -35,14 +37,15 @@ extern DigitalOut led1;
extern DigitalOut led2;
extern DigitalOut led3;
extern DigitalOut led4;
extern DigitalOut led5;
// PROJECT 1 - You can declare a DigitalOut object here

/*
* BOARD SPECIFIC PINS
*/

// PROJECT 2 - You can declare a AnalogIn object here

extern AnalogIn potentiometer1;

/*
* BOARD SPECIFIC PIN OBJECT DECLARATIONS
Expand Down
60 changes: 59 additions & 1 deletion Firmware/project_1/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "CAN/can_id.h"
#include "CAN/can_data.h"
#include "can_buffer.h"
#include "pins.h"


/*
Expand Down Expand Up @@ -95,11 +96,68 @@ int main() {
common.toggleReceiveCANLED();
}

if(timing.tickThreshold(last_task_1_time, TASK_1_RATE_US)){
if(timing.tickThreshold(last_task_1_time, TASK_1_RATE_US))
{
//PROJECT 1 - add code here to actually make the LED blink
if (led5.read()==0)
{
led.write(1);
}
else
{
led.write(0);
}
}

//PROJECT 2 - use the potentiometer to change the blink rate
while (!shutdown)
{
float volta = potentiometer1.read();
bool overflow;
uint32_t now = common.loopTime(&timing, &overflow);

//clear CAN Buffer
while(!common.readCANMessage(msg))
{
//you should do something with the relevant CAN messages here
//toggle the CAN receive LED for only the messages you need to
//receive for this board to function. This should be only a few
//total messages. Do nothing for irrelevant messages
common.toggleReceiveCANLED();
}
if (volta>0.5)
{
if(timing.tickThreshold(last_task_1_time, TASK_1_RATE_US-volta*100)) //I want to decrease the
{ //interval (increase the rate) by subtracting
if (led5.read()==0) //voltage from the potentiometer1
{ //from the default TASK_1_RATE_US
led.write(1);
}
else
{
led.write(0);
}
}

}
else //I want to increase the
{ //interval (decrease the rate) by subtracting
//from the default TASK_1_RATE_US if voltage
if(timing.tickThreshold(last_task_1_time, abs(TASK_1_RATE_US+volta*100)))//>0.5
{
//PROJECT 1 - add code here to actually make the LED blink
if (led5.read()==0)
{
led.write(1);
}
else
{
led.write(0);
}
}

}
}


}
Expand Down
2 changes: 2 additions & 0 deletions Firmware/project_1/src/pins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

// PROJECT 2 - You can instantiate your AnalogIn object here
AnalogIn potentiometer1(P_POTENTIOMETER1);

/*
* COMMON PIN OBJECT INSTANTIATIONS
Expand All @@ -22,4 +23,5 @@ DigitalOut led1(P_LED1);
DigitalOut led2(P_LED2);
DigitalOut led3(P_LED3);
DigitalOut led4(P_LED4);
DigitalOut led5(P_LED5);
// PROJECT 1 - You can instantiate your DigitalOut object here
Loading