30.12.2014 Views

QDK PIC24/dsPIC-C30 - Quantum Leaps

QDK PIC24/dsPIC-C30 - Quantum Leaps

QDK PIC24/dsPIC-C30 - Quantum Leaps

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>QDK</strong><br />

<strong>PIC24</strong>/<strong>dsPIC</strong>-<strong>C30</strong><br />

www.state-machine.com/pic<br />

3 Non-Preemptive “Vanilla” Port<br />

The “vanilla” port shows how to use QP on a bare metal <strong>PIC24</strong>-<strong>dsPIC</strong>-based system with the<br />

cooperative “vanilla” kernel. In this version you’re using the non-preemptive kernel built-into the QF<br />

framework and your’e not using the QK component.<br />

3.1 The qep_port.h Header File<br />

The QEP header file for the <strong>PIC24</strong>/<strong>dsPIC</strong> port is located in \ports\pic24-dspic\vanilla\mplabc30\qep_port.h.<br />

Listing 2 shows the qep_port.h header file for <strong>PIC24</strong>/<strong>dsPIC</strong>.<br />

NOTE: The QP port to the cooperative “Vanilla” kernel qep_port.h is generic and should not need<br />

to change for other <strong>PIC24</strong>/<strong>dsPIC</strong> applications.<br />

Listing 2: qep_port.h header file for the cooperative QP configuration and MPLAB-<strong>C30</strong> compiler<br />

#ifndef qep_port_h<br />

#define qep_port_h<br />

(1) #define Q_SIGNAL_SIZE 2<br />

/* 2-byte signal space (64K signals) */<br />

/* Exact-width types. WG14/N843 C99 Standard, Section 7.18.1.1 */<br />

(2) typedef signed char int8_t;<br />

typedef signed int int16_t;<br />

typedef signed long int32_t;<br />

typedef unsigned char uint8_t;<br />

typedef unsigned int uint16_t;<br />

typedef unsigned long uint32_t;<br />

#include "qep.h" /* QEP platform-independent public interface */<br />

#endif /* qep_port_h */<br />

(1) The macro Q_SIGNAL_SIZE defines the size (in bytes) of event signals. The allowed values are 1, 2,<br />

or 4 bytes. Here the value of Q_SIGNAL_SIZE is set to 2, which means that the QP application can<br />

use up to 64K different signals.<br />

(2) The C99-standard exact-width integer types are defined explicitly, because the MPLAB-<strong>C30</strong><br />

compiler does not provide the standard header file.<br />

3.2 The qf_port.h Header File<br />

The QF header file for the <strong>PIC24</strong>/<strong>dsPIC</strong> port is located in \ports\pic24-dspic\ vanilla\mplabc30\qf_port.h.<br />

This file specifies the interrupt locking/unlocking policy (QF critical section) as well as<br />

the configuration constants for QF (see Chapter 8 in [PSiCC2]).<br />

The most important porting decision you need to make in the qf_port.h header file is the policy for<br />

locking and unlocking interrupts. The <strong>PIC24</strong>/<strong>dsPIC</strong> CPU allows using the simplest “unconditional interrupt<br />

unlocking” policy (see Section 7.3.2 of the book “Practical UML Statecharts in C/C++, Second Edition”<br />

Copyright © <strong>Quantum</strong> <strong>Leaps</strong>, LLC. All Rights Reserved.<br />

12 of 35

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!