Giter VIP home page Giter VIP logo

qpn_for_8051's Introduction

qpn for 8051

qpn framework for 8051.

Modified based on qpn v6.9.0


Rebuilding the qpn specific for the 8051

File structure

~/qpn_blinky
|-- application
|   |-- application.h
|   |-- blinky.c
|   |-- blinky.h
|   |-- main.c
|   |-- qpn_conf.h
|-- bsp
|   |-- bsp.c
|   |-- bsp.h
|   |-- printer_debug.c
|   |-- printer_debug.h
|   |-- printer_polymorphism.c
|   |-- receiver_debug.c
|   |-- receiver_debug.h
|   |-- receiver_polymorphism.c
|-- common
|   |-- include
|   |   |-- helper_macros.h
|   |   |-- m_crc16.h
|   |   |-- m_fsm.h
|   |   |-- printer.h
|   |   |-- qmpool.h
|   |   |-- qset.h
|   |   |-- queue.h
|   |   |-- receiver.h
|   |-- src
|   |   |-- crc
|   |   |   |-- m_crc16.c
|   |   |-- m_fsm
|   |   |   |-- m_fsm.c
|   |   |-- printer
|   |   |   |-- printer.c
|   |   |-- qmpool
|   |   |   |-- qmp_get.c
|   |   |   |-- qmp_init.c
|   |   |   |-- qmp_put.c
|   |   |-- qset
|   |   |   |-- qset.c
|   |   |-- queue
|   |   |   |-- queue.c
|   |   |-- receiver
|   |   |   |-- receiver.c
|   |-- common.h
|-- include
|   |-- qassert.h
|   |-- qepn.h
|   |-- qfn.h
|   |-- qpn.h
|   |-- qvn.h
|-- ports
|   |-- cpu_port.h
|   |-- m_fsm_port.h
|   |-- qfn_port.c
|   |-- qfn_port.h
|-- src
|   |-- qfn
|   |   |-- qepn.c
|   |   |-- qfn.c
|   |-- qvn
|   |   |-- qvn.c
|-- README.md

Framework layers

            Application::AOs
-----------------------------------------
                        QF-nano
                        QEP-nano
  BSP       M_Fsm       QV-nano
-----------------------------------------
  ^  ^       ^  ^        ^  ^
  |  |       |  |        |  |
 common   m_fsm_port    qfn_port
-----------------------------------------
                ^ ^
                | |
                cpu_port

Framework porting

Every single file of 3 dirs followed to be modify:

~/application ~/bsp ~/ports

How me post and process events

Q_DOWN_CAST() matters and is very dangerous.

Posting

void Blinky_Evt_post(Blinky *me,
    uint8_t sig,
    uint8_t blink_on_off)
{
    p_global_evt_post_ = (QEvt *)0;
    p_global_evt_post_ = Q_NEW_EVT(&g_sys_evt_pool);
    if (p_global_evt_post_) {
        p_global_evt_post_->sig = sig;
        Q_DOWN_CAST(Blinky_Evt *, p_global_evt_post_)->blink_on_off =
            blink_on_off;
    }
    QACTIVE_POST(&me->super,
        p_global_evt_post_);

    return;
}

Processing

    // other codes ...
    case BLINKY_SIG: {
        if (Q_DOWN_CAST(Blinky_Evt *, Q_EVT(me))->blink_on_off) {
            //            0123456789012----
            PRINTF_DEBUG("LedOn        \r\n");
        }
        else {
            //            0123456789012----
            PRINTF_DEBUG("LedOff       \r\n");
        }

        break;
    }
    // other codes ...

The Printer_debug

How to log out fucking aggressively.

QF_INT_DISABLE();
//------------0123456789012----
PRINTF_DEBUG("Hello, World!\r\n");
QF_INT_ENABLE();

QF_INT_DISABLE();
PRINTF_DEBUG_START()
//-------------0123456789012----
PRINTF_DEBUG_("Hello, World!\r\n");
PRINTF_DEBUG_ASSIGN(12) = 0x88;
PRINTF_DEBUG_END()
QF_INT_ENABLE();

The Receiver_debug

In the Receiver_received_frame_process:

uint32_t debug_recv_code;
debug_recv_code =
    (((uint32_t)(me->process_frame[2])) << 24) |
        (((uint32_t)(me->process_frame[3])) << 16) |
            (((uint32_t)(me->process_frame[4])) << 8) |
                (((uint32_t)(me->process_frame[5])) << 0);

switch (debug_recv_code) {
    case 0x0001: {
        // do something
        break;
    }
    case 0x0002: {
        break;
    }
    case 0x0003: {
        break;
    }
    default: {
        // printf the recv data
        PRINTF_DEBUG_START()
        //-------------01234567890123--
        PRINTF_DEBUG_("Unexpct:      \n");
        PRINTF_DEBUG_ASSIGN(10) = me->process_frame[2];
        PRINTF_DEBUG_ASSIGN(11) = me->process_frame[3];
        PRINTF_DEBUG_ASSIGN(12) = me->process_frame[4];
        PRINTF_DEBUG_ASSIGN(13) = me->process_frame[5];
        PRINTF_DEBUG_END()

        break;
    }
}

qpn_for_8051's People

Contributors

mengrendufu avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.