Difference between revisions of "MansOS API"
(→USART) |
|||
Line 36: | Line 36: | ||
== USART == |
== USART == |
||
See mos/hil/usart.h for more details! |
|||
uint_t USARTInit(uint8_t id, uint32_t speed, uint8_t conf); |
|||
uint_t USARTSendByte(uint8_t id, uint8_t data); |
|||
uint_t USARTSendString(uint8_t id, uint8_t *data); |
uint_t USARTSendString(uint8_t id, uint8_t *data); |
||
uint_t USARTSendStringLine(uint8_t id, uint8_t *data); |
uint_t USARTSendStringLine(uint8_t id, uint8_t *data); |
||
void USARTSendData(uint8_t id, uint8_t *data, uint16_t len); |
void USARTSendData(uint8_t id, uint8_t *data, uint16_t len); |
||
uint_t USARTEnableTX(uint8_t id); |
|||
uint_t USARTDisableTX(uint8_t id); |
|||
uint_t USARTEnableRX(uint8_t id); |
|||
uint_t USARTDisableRX(uint8_t id); |
|||
/** |
/** |
||
Line 48: | Line 58: | ||
uint_t USARTSetReceiveHandle(uint8_t id, USARTCallback_t cb); |
uint_t USARTSetReceiveHandle(uint8_t id, USARTCallback_t cb); |
||
/** |
|||
TODO |
|||
* Set callback for per-packet data receive. Stores the received bytes in |
|||
* the buffer and the callback is called when either a newline is received |
|||
* ('\n', binary value 10) or at most len bytes are received. The newline is |
|||
* also stored in the buffer |
|||
* Also enables USART RX automatically. |
|||
* After the callback, buffer is reset and reception restarts. |
|||
* Warning: Can use only one USART at a time (single buffer, single handler)! |
|||
* |
|||
* @param id - ID of the UART used (See MCU datasheet to get IDs) |
|||
* @param cb - callback function: void myCallback(uint8_t bytes). Here the |
|||
* bytes parameter contains not the last byte received but |
|||
* total received byte count (i.e., bytes stored in the buffer)! |
|||
* @param len - size of the buffer in bytes. Callback is called when len |
|||
* bytes are received (or when '\n' is received). |
|||
* When len is zero, no packet size is checked, only on newline |
|||
* reception the callback is called. |
|||
*/ |
|||
uint_t USARTSetPacketReceiveHandle(uint8_t id, USARTCallback_t cb, void *buffer, |
|||
uint16_t len); |
Revision as of 10:06, 21 September 2011
Contents
LEDs
toggleRedLed() toggleGreenLed() toggleBlueLed() toggleLed(ledNr)
redLedOn() greenLedOn() blueLedOn()
redLedOff() greenLedOff() blueLedOff()
ledOn(uint8_t ledNr) ledOff(uint8_t ledNr) bool ledIsOn(ledNr)
uint8_t getLeds() setLeds(bitmap)
Humidity sensor
void humidityInit(); // init humidity sensor, do not turn it on - called by kernel automatically, not needed in application cod void humidityOn(); // turn on humidity sensor void humidityOff(); // turn off humidity sensor uint16_t readHumidity(); // read humidity value
ADC
uint16_t adcRead(channel) uint8_t adcGetChannelCount() - how many ADC channel the mote provides
Sleep
mleep(miliseconds)
USART
See mos/hil/usart.h for more details!
uint_t USARTInit(uint8_t id, uint32_t speed, uint8_t conf);
uint_t USARTSendByte(uint8_t id, uint8_t data); uint_t USARTSendString(uint8_t id, uint8_t *data); uint_t USARTSendStringLine(uint8_t id, uint8_t *data); void USARTSendData(uint8_t id, uint8_t *data, uint16_t len);
uint_t USARTEnableTX(uint8_t id); uint_t USARTDisableTX(uint8_t id); uint_t USARTEnableRX(uint8_t id); uint_t USARTDisableRX(uint8_t id);
/** * Set callback function for per-byte data receive. The callback is called * on every received packet * @param id - ID of the UART used (See MCU datasheet to get IDs) * @param cb - callback function: void myCallback(uint8_t byte) */ uint_t USARTSetReceiveHandle(uint8_t id, USARTCallback_t cb);
/** * Set callback for per-packet data receive. Stores the received bytes in * the buffer and the callback is called when either a newline is received * ('\n', binary value 10) or at most len bytes are received. The newline is * also stored in the buffer * Also enables USART RX automatically. * After the callback, buffer is reset and reception restarts. * Warning: Can use only one USART at a time (single buffer, single handler)! * * @param id - ID of the UART used (See MCU datasheet to get IDs) * @param cb - callback function: void myCallback(uint8_t bytes). Here the * bytes parameter contains not the last byte received but * total received byte count (i.e., bytes stored in the buffer)! * @param len - size of the buffer in bytes. Callback is called when len * bytes are received (or when '\n' is received). * When len is zero, no packet size is checked, only on newline * reception the callback is called. */ uint_t USARTSetPacketReceiveHandle(uint8_t id, USARTCallback_t cb, void *buffer, uint16_t len);