1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-22 08:22:04 +03:00

Adding word datatype and cast/construction macros, bitRead(), bitWrite(), bitSet(), bitClear(), bit().

This commit is contained in:
David A. Mellis
2008-10-25 12:52:07 +00:00
parent bc153833da
commit 5800ace0b5
3 changed files with 21 additions and 16 deletions

View File

@ -12,6 +12,11 @@
#ifdef __cplusplus #ifdef __cplusplus
#include "HardwareSerial.h" #include "HardwareSerial.h"
uint16_t makeWord(uint16_t w) { return w; }
uint16_t makeWord(byte h, byte l) { return (h << 8) | l; }
#define word(...) makeWord(__VA_ARGS__)
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
// WMath prototypes // WMath prototypes

View File

@ -66,13 +66,6 @@ extern "C"{
#undef abs #undef abs
#endif #endif
//#define int(x) ((int)(x))
//#define char(x) ((char)(x))
//#define long(x) ((long)(x))
//#define byte(x) ((uint8_t)(x))
//#define float(x) ((float)(x))
//#define boolean(x) ((uint8_t)((x)==0?0:1))
#define min(a,b) ((a)<(b)?(a):(b)) #define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b)) #define max(a,b) ((a)>(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x)) #define abs(x) ((x)>0?(x):-(x))
@ -89,6 +82,18 @@ extern "C"{
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) #define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() ) #define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
#define lowByte(w) ((w) & 0xff)
#define highByte(w) ((w) >> 8)
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
typedef unsigned int word;
#define bit(b) (1 << (b))
typedef uint8_t boolean; typedef uint8_t boolean;
typedef uint8_t byte; typedef uint8_t byte;
@ -106,15 +111,6 @@ void serialWrite(unsigned char);
int serialAvailable(void); int serialAvailable(void);
int serialRead(void); int serialRead(void);
void serialFlush(void); void serialFlush(void);
void printMode(int);
void printByte(unsigned char c);
void printNewline(void);
void printString(const char *s);
void printInteger(long n);
void printHex(unsigned long n);
void printOctal(unsigned long n);
void printBinary(unsigned long n);
void printIntegerInBase(unsigned long n, unsigned long base);
unsigned long millis(void); unsigned long millis(void);
void delay(unsigned long); void delay(unsigned long);

View File

@ -49,6 +49,7 @@ Consider moving millis() to timer 1, and configuring it so the interrupt is gene
COMPUTER COMPUTER
Check RAM usage of sketches: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1224729260/0#0
Improve preprocessing of sketches: Improve preprocessing of sketches:
- Better determine which header files are included (not commented out). - Better determine which header files are included (not commented out).
- Remember the original locations of function prototypes to highlight the correct line on error. - Remember the original locations of function prototypes to highlight the correct line on error.
@ -79,6 +80,7 @@ Test find in reference on libraries.
DEVELOPMENT DEVELOPMENT
Make run.bat not open a command line window: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1223883872
Update version of the FTDI drivers (Windows). Update version of the FTDI drivers (Windows).
Remove AVR ISP and giveio drivers (Windows). Remove AVR ISP and giveio drivers (Windows).
Include the executable installer for the FTDI drivers (Windows). Include the executable installer for the FTDI drivers (Windows).
@ -99,6 +101,8 @@ DOCUMENTATION / META
Create community section of site. Create community section of site.
List of examples we'd like to have. List of examples we'd like to have.
Style guide for examples, references, and foundations. Style guide for examples, references, and foundations.
Add a Nordic board to the forum.
Add a German board to the forum.
DOCUMENTATION / NAVIGATION DOCUMENTATION / NAVIGATION