*/
#include "Timer.h"
-module AdcP {
+module AdcP @safe() {
provides {
interface Read<uint16_t>[uint8_t client];
interface ReadNow<uint16_t>[uint8_t client];
* @author Hu Siquan <husq@xbow.com>
*/
-module Atm128AdcP
+module Atm128AdcP @safe()
{
provides {
interface Init;
* @author David Gay
*/
-module HplAtm128AdcP {
+module HplAtm128AdcP @safe() {
provides interface HplAtm128Adc;
uses interface McuPowerState;
}
#define READ_FLAG(port, flag) ((port) & (flag))
/* Enables interrupts. */
-inline void __nesc_enable_interrupt() {
+inline void __nesc_enable_interrupt() @safe() {
sei();
}
/* Disables all interrupts. */
-inline void __nesc_disable_interrupt() {
+inline void __nesc_disable_interrupt() @safe() {
cli();
}
/* Saves current interrupt mask state and disables interrupts. */
inline __nesc_atomic_t
-__nesc_atomic_start(void) @spontaneous()
+__nesc_atomic_start(void) @spontaneous() @safe()
{
__nesc_atomic_t result = SREG;
__nesc_disable_interrupt();
/* Restores interrupt mask to original state. */
inline void
-__nesc_atomic_end(__nesc_atomic_t original_SREG) @spontaneous()
+__nesc_atomic_end(__nesc_atomic_t original_SREG) @spontaneous() @safe()
{
asm volatile("" : : : "memory"); /* ensure atomic section effect visibility */
SREG = original_SREG;
};
/* Combine function. */
-mcu_power_t mcombine(mcu_power_t m1, mcu_power_t m2) {
+mcu_power_t mcombine(mcu_power_t m1, mcu_power_t m2) @safe() {
return (m1 < m2)? m1: m2;
}
* @param b Byte to "add" to the CRC
* @return New CRC value
*/
-uint16_t crcByte(uint16_t oldCrc, uint8_t byte) __attribute__((noinline))
+uint16_t crcByte(uint16_t oldCrc, uint8_t byte) __attribute__((noinline)) @safe()
{
#if 1
uint16_t *table = crcTable;
/**
* @author Phil Levis
*/
-generic module Atm128GpioInterruptC() {
+generic module Atm128GpioInterruptC() @safe() {
provides interface GpioInterrupt as Interrupt;
uses interface HplAtm128Interrupt as Atm128Interrupt;
*
* @author Martin Turon <mturon@xbow.com>
*/
-module HplAtm128InterruptSigP
+module HplAtm128InterruptSigP @safe()
{
provides interface HplAtm128InterruptSig as IntSig0;
provides interface HplAtm128InterruptSig as IntSig1;
#include "Atm128Spi.h"
-module HplAtm128SpiP {
+module HplAtm128SpiP @safe() {
provides interface Atm128Spi as SPI;
provides interface AsyncStdControl;
generic module Atm128AlarmC(typedef frequency_tag,
typedef timer_size @integer(),
- int mindt)
+ int mindt) @safe()
{
provides interface Alarm<frequency_tag, timer_size> as Alarm @atmostonce();
*/
generic module Atm128CounterC(typedef frequency_tag,
- typedef timer_size @integer())
+ typedef timer_size @integer()) @safe()
{
provides interface Counter<frequency_tag,timer_size> as Counter;
uses interface HplAtm128Timer<timer_size> as Timer;
*
* @author Martin Turon, Crossbow <mturon@xbow.com>
*/
-generic module Atm128GpioCaptureC() {
+generic module Atm128GpioCaptureC() @safe() {
provides interface GpioCapture as Capture;
uses interface HplAtm128Capture<uint16_t> as Atm128Capture;
* @author David Gay <david.e.gay@intel.com>
*/
-generic module Atm128TimerInitC(typedef timer_size @integer(), uint8_t prescaler)
+generic module Atm128TimerInitC(typedef timer_size @integer(), uint8_t prescaler) @safe()
{
provides interface Init @atleastonce();
uses interface HplAtm128Timer<timer_size> as Timer;
* @author Jaein Jeong
* @author David Gay
*/
-module CC1000ControlP {
+module CC1000ControlP @safe() {
provides {
interface CC1000Control;
}
* the stack.
*/
-module CC1000RssiP
+module CC1000RssiP @safe()
{
provides {
interface ReadNow<uint16_t> as Rssi[uint8_t reason];
* @author David Gay
*/
-module CC1000SquelchP
+module CC1000SquelchP @safe()
{
provides {
interface Init;
// creating potentially broken object code. Union casts are the appropriate work
// around. Unfortunately, they require a function definiton.
#define DEFINE_UNION_CAST(func_name,to_type,from_type) \
-to_type func_name(from_type x) { union {from_type f; to_type t;} c = {f:x}; return c.t; }
+to_type func_name(from_type x) @safe() { union {from_type f; to_type t;} c = {f:x}; return c.t; }
// redefine ugly defines from msp-gcc
#ifndef DONT_REDEFINE_SR_FLAGS
// be detectde by nesc.
#define TOSH_ASSIGN_PIN_HEX(name, port, hex) \
-void TOSH_SET_##name##_PIN() { MSP430REG_NORACE2(r,P##port##OUT); r |= hex; } \
-void TOSH_CLR_##name##_PIN() { MSP430REG_NORACE2(r,P##port##OUT); r &= ~hex; } \
-void TOSH_TOGGLE_##name##_PIN() { MSP430REG_NORACE2(r,P##port##OUT); r ^= hex; } \
-uint8_t TOSH_READ_##name##_PIN() { MSP430REG_NORACE2(r,P##port##IN); return (r & hex); } \
-void TOSH_MAKE_##name##_OUTPUT() { MSP430REG_NORACE2(r,P##port##DIR); r |= hex; } \
-void TOSH_MAKE_##name##_INPUT() { MSP430REG_NORACE2(r,P##port##DIR); r &= ~hex; } \
-void TOSH_SEL_##name##_MODFUNC() { MSP430REG_NORACE2(r,P##port##SEL); r |= hex; } \
-void TOSH_SEL_##name##_IOFUNC() { MSP430REG_NORACE2(r,P##port##SEL); r &= ~hex; }
+void TOSH_SET_##name##_PIN() @safe() { MSP430REG_NORACE2(r,P##port##OUT); r |= hex; } \
+void TOSH_CLR_##name##_PIN() @safe() { MSP430REG_NORACE2(r,P##port##OUT); r &= ~hex; } \
+void TOSH_TOGGLE_##name##_PIN() @safe(){ MSP430REG_NORACE2(r,P##port##OUT); r ^= hex; } \
+uint8_t TOSH_READ_##name##_PIN() @safe() { MSP430REG_NORACE2(r,P##port##IN); return (r & hex); } \
+void TOSH_MAKE_##name##_OUTPUT() @safe() { MSP430REG_NORACE2(r,P##port##DIR); r |= hex; } \
+void TOSH_MAKE_##name##_INPUT() @safe() { MSP430REG_NORACE2(r,P##port##DIR); r &= ~hex; } \
+void TOSH_SEL_##name##_MODFUNC() @safe() { MSP430REG_NORACE2(r,P##port##SEL); r |= hex; } \
+void TOSH_SEL_##name##_IOFUNC() @safe() { MSP430REG_NORACE2(r,P##port##SEL); r &= ~hex; }
#define TOSH_ASSIGN_PIN(name, port, bit) \
TOSH_ASSIGN_PIN_HEX(name,port,(1<<(bit)))
typedef uint8_t mcu_power_t @combine("mcombine");
-mcu_power_t mcombine(mcu_power_t m1, mcu_power_t m2) {
+mcu_power_t mcombine(mcu_power_t m1, mcu_power_t m2) @safe() {
return (m1 < m2) ? m1: m2;
}
enum {
MSP430_POWER_LPM4 = 5
};
-void __nesc_disable_interrupt(void)
+void __nesc_disable_interrupt(void) @safe()
{
dint();
nop();
}
-void __nesc_enable_interrupt(void)
+void __nesc_enable_interrupt(void) @safe()
{
eint();
}
is #defined, to avoid duplicate functions definitions wheb binary
components are used. Such functions do need a prototype in all cases,
though. */
-__nesc_atomic_t __nesc_atomic_start(void) @spontaneous()
+__nesc_atomic_t __nesc_atomic_start(void) @spontaneous() @safe()
{
__nesc_atomic_t result = ((READ_SR & SR_GIE) != 0);
__nesc_disable_interrupt();
return result;
}
-void __nesc_atomic_end(__nesc_atomic_t reenable_interrupts) @spontaneous()
+void __nesc_atomic_end(__nesc_atomic_t reenable_interrupts) @spontaneous() @safe()
{
asm volatile("" : : : "memory"); /* ensure atomic section effect visibility */
if( reenable_interrupts )
* intended use.
*/
-generic module Msp430InterruptC() {
+generic module Msp430InterruptC() @safe() {
provides interface GpioInterrupt as Interrupt;
uses interface HplMsp430Interrupt as HplInterrupt;
* @version $Revision$ $Date$
*/
-generic module Msp430UsartShareP() {
+generic module Msp430UsartShareP() @safe() {
provides interface HplMsp430UsartInterrupts as Interrupts[ uint8_t id ];
provides interface HplMsp430I2CInterrupts as I2CInterrupts[ uint8_t id ];
* @author Kevin Klues (klueska@cs.wustl.edu)
*/
-generic module AsyncPowerManagerP() {
+generic module AsyncPowerManagerP() @safe() {
uses {
interface AsyncStdControl;
* @author David Gay
*/
-module BusyWaitMicroC
+module BusyWaitMicroC @safe()
{
provides interface BusyWait<TMicro,uint16_t>;
}
*
* @author David Gay
*/
-module MotePlatformP
+module MotePlatformP @safe()
{
provides interface Init as PlatformInit;
uses interface GeneralIO as SerialIdPin;
#include "Atm128Adc.h"
#include "CC1000Const.h"
-module HplCC1000P {
+module HplCC1000P @safe() {
provides {
interface Init as PlatformInit;
interface HplCC1000;
*/
-module HplCC1000SpiP {
+module HplCC1000SpiP @safe() {
provides interface Init as PlatformInit;
provides interface HplCC1000Spi;
//uses interface PowerManagement;
* @version @version $Revision$ $Date$
*/
-module HplCC2420InterruptsP {
+module HplCC2420InterruptsP @safe() {
provides {
interface GpioInterrupt as CCA;
}
* @author Miklos Maroti
*/
-module HplCC2420SpiP
+module HplCC2420SpiP @safe()
{
provides interface Resource;
// 1-Wire
TOSH_ASSIGN_PIN(ONEWIRE, 2, 4);
-void HUMIDITY_MAKE_CLOCK_OUTPUT() { TOSH_MAKE_HUM_SCL_OUTPUT(); }
-void HUMIDITY_MAKE_CLOCK_INPUT() { TOSH_MAKE_HUM_SCL_INPUT(); }
-void HUMIDITY_CLEAR_CLOCK() { TOSH_CLR_HUM_SCL_PIN(); }
-void HUMIDITY_SET_CLOCK() { TOSH_SET_HUM_SCL_PIN(); }
-void HUMIDITY_MAKE_DATA_OUTPUT() { TOSH_MAKE_HUM_SDA_OUTPUT(); }
-void HUMIDITY_MAKE_DATA_INPUT() { TOSH_MAKE_HUM_SDA_INPUT(); }
-void HUMIDITY_CLEAR_DATA() { TOSH_CLR_HUM_SDA_PIN(); }
-void HUMIDITY_SET_DATA() { TOSH_SET_HUM_SDA_PIN(); }
-char HUMIDITY_GET_DATA() { return TOSH_READ_HUM_SDA_PIN(); }
+void HUMIDITY_MAKE_CLOCK_OUTPUT() @safe() { TOSH_MAKE_HUM_SCL_OUTPUT(); }
+void HUMIDITY_MAKE_CLOCK_INPUT() @safe() { TOSH_MAKE_HUM_SCL_INPUT(); }
+void HUMIDITY_CLEAR_CLOCK() @safe() { TOSH_CLR_HUM_SCL_PIN(); }
+void HUMIDITY_SET_CLOCK() @safe() { TOSH_SET_HUM_SCL_PIN(); }
+void HUMIDITY_MAKE_DATA_OUTPUT() @safe() { TOSH_MAKE_HUM_SDA_OUTPUT(); }
+void HUMIDITY_MAKE_DATA_INPUT() @safe() { TOSH_MAKE_HUM_SDA_INPUT(); }
+void HUMIDITY_CLEAR_DATA() @safe() { TOSH_CLR_HUM_SDA_PIN(); }
+void HUMIDITY_SET_DATA() @safe() { TOSH_SET_HUM_SDA_PIN(); }
+char HUMIDITY_GET_DATA() @safe() { return TOSH_READ_HUM_SDA_PIN(); }
#define HUMIDITY_TIMEOUT_MS 30
#define HUMIDITY_TIMEOUT_TRIES 20
*
* @author David Gay
*/
-generic module ArbitratedReadC(typedef width_t) {
+generic module ArbitratedReadC(typedef width_t) @safe() {
provides interface Read<width_t>[uint8_t client];
uses {
interface Read<width_t> as Service[uint8_t client];
*
* @author David Gay <david.e.gay@intel.com>
*/
-module NoInitC
+module NoInitC @safe()
{
provides interface Init;
}
#include "Resource.h"
-generic module RoundRobinResourceQueueC(uint8_t size) {
+generic module RoundRobinResourceQueueC(uint8_t size) @safe() {
provides {
interface Init;
interface ResourceQueue as RoundRobinQueue;
* @author Philip Levis
*/
-generic module SimpleArbiterP() {
+generic module SimpleArbiterP() @safe() {
provides {
interface Resource[uint8_t id];
interface ResourceRequested[uint8_t id];
typedef uint8_t error_t NESC_COMBINE("ecombine");
-error_t ecombine(error_t r1, error_t r2)
+error_t ecombine(error_t r1, error_t r2) @safe()
/* Returns: r1 if r1 == r2, FAIL otherwise. This is the standard error
combination function: two successes, or two identical errors are
preserved, while conflicting errors are represented by FAIL.