ROM Comm / Mbed 2 deprecated espar_mini_control_CAN

Dependencies:   mbed mbed-STM32F103C8T6

main.cpp

Committer:
lorded
Date:
2020-06-10
Revision:
8:2b0d18ebbba9
Parent:
7:467e350d1a10
Child:
9:6126b83608be

File content as of revision 8:2b0d18ebbba9:

/*

mbed Can-Bus ECU simulator

v1.0 December 2014

********************************************************************************

WARNING: Use at your own risk, sadly this software comes with no guarantees.
This software is provided 'free' and in good faith, but the author does not
accept liability for any damage arising from its use.

********************************************************************************

*/
//#include "MapleMini.h"
#include "stm32f103c8t6.h"
#include "mbed.h"
#include "ecu_simulator.h"
#include "globals.h"
#include "heatcontrol.h"

// pinout for Maple Mini
DigitalIn click(PA_1);   // Button inputs
// pinout for lpc1768
//DigitalIn click(p21);   // Joystick inputs
//DigitalIn right(p22);
//DigitalIn down(p23);
//DigitalIn left(p24);
//DigitalIn up(p25);

ecu_sim sim(CANSPEED_500);     //Create object and set CAN speed
ecu_t ecu;

Ticker timer;

void attime() 
{
    //second_tick = true;
    //myled = !myled;
    led1 = !led1;
}

// Menu defines

//unsigned char menu_state;
//unsigned char canspeed;

// external variables
volatile unsigned char idletimer;
char printbuff[256];

void DebugWrite(const char* str) {
    pc.printf(str);    
}
void resetTimer(struct sHeatVars *s) {
    //TODO: This.
}
void resetTimerAsync(struct sHeatVars *s) {
    //TODO: This.
}
int main() 
{
    confSysClock();     //Configure system clock (72MHz HSE clock, 48MHz USB clock)
    pc.baud(115200);
    
    //Enable Pullup 
    click.mode(PullUp);

    
    pc.printf("\n\nRIXEN Simulator v1.1 \r\n"); 
      
    led1 = 1;
    wait(0.1);
    led2 = 1;
    wait(0.1);
    led3 = 1;
    wait(0.1);
    led4 = 1;
    wait(0.2);
    led1 = 0; led2 = 0; led3 = 0; led4 = 0;
       
    
    wait(1);
    
    //canspeed = CAN500;
    ecu.dtc = false;
    ecu.active_fault = false;
    
    sim.canspeed(CANSPEED_500); 
    
    wait(0.2);
    led1 = 1;
    
    timer.attach(&attime, 1);
    
    
    initHeaterState(&heaterState[0]);
    initHeaterState(&heaterState[1]);

    heaterState[0].bustype = HEATERTYPECAN;
    heaterState[0].heaternum = 1;
    
    heaterState[1].bustype = HEATERTYPENONE;
    

    while(1)  // Main CAN loop
    {
        
        for (int i = 0; i < HEATERSTATECOUNT; i++)
        {
//            wiced_update_system_monitor(&main_thread_monitor, 10 * 1000);
            doHeatTaskCAN(&heaterState[i]);
//            wiced_update_system_monitor(&main_thread_monitor, 10 * 1000);
            doHeatLogicTask(&heaterState[i]);
            if (i < HEATERSTATECOUNT)
            {
                wait_ms(50);
            }
            else
            {
                //wiced_rtos_delay_milliseconds(50);
            }
        }
    }
}