Simple "Blinky" example for the QP active object framework

Dependencies:   mbed qp

Fork of qp_dpp by Quantum Leaps

Revision:
7:80bbc7a6c78c
Parent:
4:6189d844a1a2
--- a/bsp.cpp	Wed Sep 05 14:03:05 2012 +0000
+++ b/bsp.cpp	Sun Oct 12 18:56:53 2014 +0000
@@ -1,39 +1,5 @@
-//////////////////////////////////////////////////////////////////////////////
-// Product: DPP example, configurable Vanilla/QK kernel
-// Last Updated for Version: 4.5.02
-// Date of the Last Update:  Sep 04, 2012
-//
-//                    Q u a n t u m     L e a P s
-//                    ---------------------------
-//                    innovating embedded systems
-//
-// Copyright (C) 2002-2012 Quantum Leaps, LLC. All rights reserved.
-//
-// This program is open source software: you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as published
-// by the Free Software Foundation, either version 2 of the License, or
-// (at your option) any later version.
-//
-// Alternatively, this program may be distributed and modified under the
-// terms of Quantum Leaps commercial licenses, which expressly supersede
-// the GNU General Public License and are specifically designed for
-// licensees interested in retaining the proprietary status of their code.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
-//
-// Contact information:
-// Quantum Leaps Web sites: http://www.quantum-leaps.com
-//                          http://www.state-machine.com
-// e-mail:                  info@quantum-leaps.com
-//////////////////////////////////////////////////////////////////////////////
 #include "qp_port.h"
-#include "dpp.h"
+#include "blinky.h"
 #include "bsp.h"
 #include "LPC17xx.h"
 #ifdef Q_SPY
@@ -41,8 +7,6 @@
 #endif
 
 //////////////////////////////////////////////////////////////////////////////
-namespace DPP {
-
 Q_DEFINE_THIS_FILE
 
 enum ISR_Priorities {      // ISR priorities starting from the highest urgency
@@ -52,8 +16,6 @@
 };
 
 // Local-scope objects -------------------------------------------------------
-static uint32_t l_rnd;                                          // random seed
-
 #define LED_PORT      LPC_GPIO1
 #define LED1_BIT     (1U << 18)
 #define LED2_BIT     (1U << 20)
@@ -67,10 +29,6 @@
 
     #define QSPY_BAUD_RATE  115200U
 
-    enum AppRecords {                    // application-specific trace records
-        PHILO_STAT = QP::QS_USER
-    };
-
     Serial l_qspy(USBTX, USBRX);
 #endif
 
@@ -98,7 +56,7 @@
     
                                                              // clear the LEDs
     LED_PORT->FIOCLR  = (LED1_BIT | LED2_BIT | LED3_BIT | LED4_BIT);
-
+ 
                                       // initialize the QS software tracing...
     Q_ALLEGE(QS_INIT(static_cast<void *>(0)));
     QS_RESET();
@@ -109,38 +67,12 @@
     (void)result;
 }
 //............................................................................
-void BSP_displayPhilStat(uint8_t const n, char_t const * const stat) {
-                            // represent LEDs in a const array for convenience
-    static uint32_t const led[] = { LED1_BIT, LED2_BIT, LED3_BIT, LED4_BIT };
-    if (n < 3) {
-        if (stat[0] == 'e') {
-            LED_PORT->FIOSET = led[n];
-        }
-        else {
-            LED_PORT->FIOCLR = led[n];
-        }
-    }
-    
-    QS_BEGIN(PHILO_STAT, AO_Philo[n])     // application-specific record begin
-        QS_U8(1U, n);                                    // Philosopher number
-        QS_STR(stat);                                    // Philosopher status
-    QS_END()
+void BSP_ledOn(void) {
+    LED_PORT->FIOSET = LED1_BIT;
 }
 //............................................................................
-void BSP_displayPaused(uint8_t const paused) {
-    (void)paused;
-}
-//............................................................................
-uint32_t BSP_random(void) {     // a very cheap pseudo-random-number generator
-    // "Super-Duper" Linear Congruential Generator (LCG)
-    // LCG(2^32, 3*7*11*13*23, 0, seed)
-    //
-    l_rnd = l_rnd * (3U*7U*11U*13U*23U);
-    return l_rnd >> 8;
-}
-//............................................................................
-void BSP_randomSeed(uint32_t const seed) {
-    l_rnd = seed;
+void BSP_ledOff(void) {
+    LED_PORT->FIOCLR = LED1_BIT;
 }
 
 //............................................................................
@@ -155,19 +87,17 @@
     }
 }
 
-}                                                             // namespace DPP
 //////////////////////////////////////////////////////////////////////////////
-
 namespace QP {
 
 //............................................................................
 void QF::onStartup(void) {
                  // set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate
-    (void)SysTick_Config(SystemCoreClock / DPP::BSP_TICKS_PER_SEC);
+    (void)SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC);
 
                           // set priorities of all interrupts in the system...
-    NVIC_SetPriority(SysTick_IRQn, DPP::SYSTICK_PRIO);
-    NVIC_SetPriority(EINT0_IRQn,   DPP::GPIOPORTA_PRIO);
+    NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO);
+    NVIC_SetPriority(EINT0_IRQn,   GPIOPORTA_PRIO);
 
     NVIC_EnableIRQ(EINT0_IRQn);
 }
@@ -207,7 +137,7 @@
     // Specifially for the mbed board, see the articles:
     // * "Power Management" http://mbed.org/cookbook/Power-Management; and
     // * "Interface Powerdown" at 
-    //   http://mbed.org/users/simon/notebook/interface-powerdown/
+    // http://mbed.org/users/simon/notebook/interface-powerdown/
     // 
     __WFI();
 #endif
@@ -244,7 +174,7 @@
     // Specifially for the mbed board, see the articles:
     // * "Power Management" http://mbed.org/cookbook/Power-Management; and
     // * "Interface Powerdown" at 
-    //   http://mbed.org/users/simon/notebook/interface-powerdown/
+    //    http://mbed.org/users/simon/notebook/interface-powerdown/
     // 
     __WFI();
     QF_INT_ENABLE();