ARMV5::ARMV5(sc_module_name name, uint32_t addr, bool using_gdb, unsigned int gdb_port): sc_module(name) { this->core_id = 0; cp15.c0_idcode = 0x41069265; cp15.c0_cachetype = 0x1dd20d2; cp15.c0_cachetype = 0x1d112152; gdb = 0; this->using_gdb = using_gdb; this->gdb_port = gdb_port; gdb_init = false; using_prog = false; bkptRemove(); // clear all break points watchRemove(); // clear all watch points rfInit(addr); cpInit(); cacheInit(); delay = 0; mmu_enable = false; icache_enable = false; dcache_enable = false; vectorHi = false; /* start to simulate */ SC_THREAD(run); sensitive << clk.pos(); //dont_initialize(); SC_METHOD(shared_event_listener); sensitive << ARMV5::shared_event; SC_METHOD(irq_n_listener); sensitive << irq_n.neg(); }
// ----------------------------------------------------------------------------- // Le programme principal int main (void) { vLedInit(); vSerialInit (DEBUG_BAUDRATE / 100, SERIAL_DEFAULT + SERIAL_RW); stdout = &xSerialPort; printf_P (PSTR("\r\riDwaRF - Firmware v" __IDWARF_VERSION_STRING__ " Hub version\n\n")); // initialise le firmware iDwaRF printf_P(PSTR("Init... ")); rfInit(); // les interruptions sont validées... vPrintOk(); // Enregistre les fonctions de traitement de l'utilisateur printf_P(PSTR("Register Call Back functions... ")); rfRegisterCBSensorDataReceived (vSensorPacketReceived); vPrintOk(); vPrintStatus(); vPrintBeaconTime(); vPrintHelp(); puts_P(PSTR("\nProcess All ...")); for (;;) { // la boucle principale gère les événements du réseau... rfProcessAll(); // if the serial callback has set this flag, there is new data to be processed. // done here to prevent overload in the callback function if (usSerialHit()) { vProcessRxData(); } // show the saved data received with the last sensor packet // OutStr takes some time - that's the reason why it is done here! // ucData holds the data and ucDataLen is the amount of data stored in ucData. if (ucDataLen > 0) { uint8_t * pucData = ucData; if ((ucFlags & HEX_FLAG) == 0) { // show data user friendly if (ucDataLen >= 1) { // Push Button state - 1 byte printf_P (PSTR("Button %s"), (*pucData++ != 0 ? "ON " : "off")); } if (ucDataLen >= 2) { uint8_t ucBatt; // Battery voltage - 1 byte ucBatt = *pucData++; printf_P (PSTR(" Batt <0x%02X> %.2fV"), ucBatt, ADC_SCALE * (float) ucBatt / 256.0); } if (ucDataLen >= 4) { int16_t iTemp; // Temperature value - 2 bytes iTemp = (*pucData++) << 8; iTemp += *pucData++; printf_P (PSTR(" Temp (0x%02X) %.1foC"), iTemp, (float)iTemp / 10.0); } if (ucDataLen >= 5) { // Light Dependent Resistor value - 1 byte printf_P (PSTR(" Ldr %d"), *pucData++); } } while (pucData < (ucData + ucDataLen)) { printf_P (PSTR("%02X "), *pucData++); } // show the payload size printf_P (PSTR("> len=%d\n"), ucDataLen); ucDataLen = 0; // reset. Otherwise this data is displayed non stop. } } }
// ----------------------------------------------------------------------------- // the main entry for the user Software int main (void) { bool xOldButton = false; vLedInit(); vButInit(); prvvDebugInit(); vDbgPuts_P (PSTR("Testcode for the tutorial - hub style\r")); // initialize the RF - Firmware rfInit(); // register callback: function called, each time a sensor data packet is received rfRegisterCBSensorDataReceived (cbSensorPacketReceived); // the main loop for (;;) { if (xButGet(BUTTON) == BUTTON) { if (xOldButton == false) { // debug output for (uint8_t n = 0; n < 10; n ++) { vDbgPutDec (ucValid[n]); vDbgPutc ('.'); } vDbgPutc (' '); // search for the next value sensor id for (ucValue++; ucValue < 10; ucValue++) { if (ucValid[ucValue]) break; } if (ucValue == 10) { // if overflow | no sensor ucValid, search again for (ucValue = 0; ucValue < 10; ucValue++) { if (ucValid[ucValue]) break; } } if (ucValue == 10) ucValue = 0; // no sensor ucValid - fallback to id 0 // debug output vDbgPutDec (ucValue); vDbgPutc (' '); // mark all sensors as not ucValid for the next iteration for (uint8_t n = 0; n < 10; n++) { ucValid[n] = 0; } xOldButton = true; } } else { if (xOldButton == true) xOldButton = false; } rfProcessAll(); } }
void main( void ) { u8 i, ucChar, *ucEeproms, ucBuffer[ 40 ]; sysInit(); socketInit(); rfInit(); print( COM3, "\rV2 RFID: 0x%X", socketGetID()); //mpl115a2Init( TX1, RX1, NONE, NONE ); //print( COM3, "\rPressure: %f", mpl115a2ReadkPa() ); //print( COM3, "\rTemp: %f", mpl115a2ReadTemp() ); //i2cConfig( &globalGasSensorDigipot, DIGIPOT_BASEADDRESS|3, TX1, RX1, I2CSPEEDFAST ); //digipotSetWiper( &globalGasSensorDigipot, 2, 0 ); //eepromOpen( 0x2F, TX1, RX1, NONE ); //eepromPutString( 0, "Test" ); pinConfig( MCO, OUT ); pinSet( MCO, HIGH ); gasSensorInit(); //print( COM3, "\rGas Sensor: %f", gasSensorRead() ); //gasSensorSetGain( 0,0 ); //print( COM3, "\rGas Sensor: %f", gasSensorRead() ); //gasSensorSetGain( 200,200 ); //print( COM3, "\rGas Sensor: %f", gasSensorRead() ); //eepromGetBuffer( 0, ucBuffer, len( "test" ) ); //print( COM3, "\rEeprom: ucBuffer ); //print( COM3, "\rEEPROM Direct Read: " ); /*for( i = 0; i < len( "test" ); i++ ){ ucChar = eepromGetChar( i ); if( isAlphaOrNumeric( ucChar ) ) { print( COM3, "%c", ucChar ); } else{ print( COM3, "(%d)", ucChar );//ucBuffer, len( "humidity" ) ); } // else } // for */ /* // Test for LCD code if( isStringSame( ucBuffer, "<shield lcd>" ) ){ print( COM3, "\rLCD Shield Detected" ); fileOpenResource( &fileFont, (u8*)PYGMY_orbitron18 ); fontLoad( &fileFont, &fontOrbitron18 ); fontSetAll( &fontOrbitron18 ); pinConfig( A0, PULLUP ); pinConfig( D3, PULLUP ); pinConfig( TA0, PULLUP ); pinConfig( DAC1, PULLUP ); pinConfig( DAC2, PULLUP ); pinConfig( TX2, PULLUP ); pinConfig( RX2, PULLUP ); drawMainMenu(); } else{ hih5030Init( A2, A3 ); } // else */ //taskNewSimple( "humidity", 1000, (void*)threadRFHumiditySave ); //gemInit(); //fileOpen( &pygmyFile, "picon128", READ ); //drawImage( 0,0, &pygmyFile, 0 ); /*ucBuffer = sysAllocate( 5 ); copyString( "Test", ucBuffer ); ucBuffer = sysReallocate( ucBuffer, 20 ); appendString( "ThisToo", ucBuffer ); print( COM3, "\rTest String: %s", ucBuffer );*/ //pinConfig( SHIELD_CENTER, PULLUP ); //pinInterrupt( gemClickMenu, SHIELD_CENTER, TRIGGER_RISING|TRIGGER_FALLING ); //drawRect( 0, 20, 127, 40, VISIBLE|BORDER|ROUNDED, 8); //gemDrawMenu(); //drawWidget( &btnOK ); //gemInit(); //sysFree( ucBuffer ); //fileOpen( &pygmyFile, "jpeg", READ ); //drawJPEG( &pygmyFile, 0, 0 ); //drawPNG( &pygmyFile, 0, 0 ); /*mstatsTemp mstats(); print( COM3, "\rbytes_total: %d", bytes_total ); print( COM3, "\rchunks_used: %d", chunks_used ); print( COM3, "\rbytes_used: %d", bytes_used ); print( COM3, "\rchunks_free: %d", chunks_free ); print( COM3, "\rbytes_free: %d", bytes_free );*/ while(1){;} }