I understand the following code will all run on one core. I want to run the "logicThread" on stdcore[1] and everything else on the stdcore[0]. However I can't work out how to do this.
Code: Select all
#include <xs1.h>
#include <print.h>
#include <platform.h>
// Ports
#define PORT_CLED_0 XS1_PORT_4C // "Clock" LEDs
#define PORT_CLED_GR XS1_PORT_1E // Green/Red select lines
#define FLASH_PERIOD 100000000
// Ports
out port p_cled_g = PORT_CLED_GR;
out port p_cled_0 = PORT_CLED_0;
void ledDriver(chanend c_led){
p_cled_g <: 1;
while (1) {
unsigned char c_led_;
c_led :> c_led_;
p_cled_0 <: c_led_;
}
}
void logicThread(chanend c) {
timer tmr;
unsigned t;
unsigned char ledStatus = 0b1111;
tmr :> t;
while (1) {
t += FLASH_PERIOD;
tmr when timerafter(t) :> void;
ledStatus = ~ledStatus;
c <: ledStatus;
}
}
int main() {
chan c;
par
{
ledDriver(c);
logicThread(c);
}
return 0;
}
Code: Select all
#include <xs1.h>
#include <print.h>
#include <platform.h>
// Ports
#define PORT_CLED_0 XS1_PORT_4C // "Clock" LEDs
#define PORT_CLED_GR XS1_PORT_1E // Green/Red select lines
#define FLASH_PERIOD 100000000
// Ports
on stdcore [0] : out port p_cled_g = PORT_CLED_GR;
on stdcore [0] : out port p_cled_0 = PORT_CLED_0;
void ledDriver(chanend c_led){
p_cled_g <: 1;
while (1) {
unsigned char c_led_;
c_led :> c_led_;
p_cled_0 <: c_led_;
}
}
void logicThread(chanend c) {
timer tmr;
unsigned t;
unsigned char ledStatus = 0b1111;
tmr :> t;
while (1) {
t += FLASH_PERIOD;
tmr when timerafter(t) :> void;
ledStatus = ~ledStatus;
c <: ledStatus;
}
}
int main() {
chan c;
par
{
on stdcore [0] : ledDriver(c);
on stdcore [1] : logicThread(c);
}
return 0;
}
Any help appreciated
Chendy