%{^const uint8_t packet[131];const uint8_t *packetCount = packet;const uint8_t *packetHeader = packet + 1;const uint8_t *packetContents = packet + 2;
%}
macdef packet = $extval(arrayref(uint8, 131),"packet")
macdef packetCount = $extval(ref(uint8),"packetCount")
val by = serial_poll_for_byte(): uint8 val _ = print! by
val _ = !packetCount = by val _ = print! (!packetCount)
--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/00418f48-119e-4792-8d5f-de27bd760f41%40googlegroups.com.
// SATS file
fun pec_add (old: uint8, new: uint8): uint8
// DATS file
extern fun{} n8 (x: uint8): natLt(256) implement{} n8 (x) = cast{natLt(256)}(x) // Can't go wrong because they are the same size
%{^const uint8_t crcLookupTable[256] PROGMEM = { 0, 7, 14, 9, 28, 27, 18, 21, 56, 63, 54, 49, 36, 35, 42, 45, 112, 119, 126, 121, 108, 107, 98, 101,...... };%}
macdef crcLookupTable = $extval(arrayref(uint8,256),"crcLookupTable")
implement pec_add (old, new) = crcLookupTable[n8(new)]
// APP DATS File
val pec = pec_add(ZERO, u8(4)) val _ = print! pec
--
You received this message because you are subscribed to the Google Groups "ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/f051fce6-bffe-476c-abef-b68995de0570%40googlegroups.com.
#include "config.hats"#include "{$TOP}/avr_prelude/kernel_staload.hats"staload "prelude/SATS/bool.sats"staload "prelude/SATS/unsafe.sats"
staload "{$TOP}/SATS/arduino.sats"staload "{$TOP}/SATS/hardware_serial.sats"staload "{$TOP}/SATS/i2c.sats"#define pgm_read_byte ( address_short ) pgm_read_byte_near(address_short)
#define pgm_read_byte_near ( address_short ) __LPM((uint16_t)(address_short))
#define __LPM_enhanced__(addr) \
(__extension__({ \
uint16_t __addr16 = (uint16_t)(addr); \
uint8_t __result; \
__asm__ \
( \
"lpm %0, Z" "\n\t" \
: "=r" (__result) \
: "z" (__addr16) \
); \
__result; \
}))
abstypearrayref_vt0ype_int_type (a:vt@ype(*elt*), n:int(*size*)) = ptrstadef arrayref = arrayref_vt0ype_int_type