--
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/e5d3c479-17fa-449a-a0da-641573f976ab%40googlegroups.com.
--
--
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/7c85fe9a-3530-4b88-a65d-6527ecc12e8f%40googlegroups.com.
fun i2c_stop (arrayref(uint8, 256)) : uint8 = "mac#i2c_stop"
%{^uint8_t i2c_data[256];%}
macdef i2c_data = $extval(arrayref(uint8, 256),"i2c_data")
implement i2c_read_byte(address: uint8): (uint8, uint8) = let var b: uint8 = u8(0) var err: uint8 = err (0, u8) val () = ifnerr(i2c_start(), err, 1, u8) val () = ifnerr(i2c_write(wa address), err, 2, u8) val () = ifnerr(i2c_read(), err, 3, u8) val () = ifnerr(i2c_stop(i2c_data), err, 4, u8) in (err, i2c_data[0]) end
--
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/34bf8276-27ff-4fd9-851e-c7c37179d76e%40googlegroups.com.
--
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/f47ac698-802c-4861-8ee4-5fee0023cf89%40googlegroups.com.
implement i2c_read_byte(address: uint8): (uint8, uint8) = let
--
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/a884f717-2c44-495a-ac84-eba74765ee57%40googlegroups.com.
fun i2c_write_byte_data (uint8, uint8, uint8) : uint8implement i2c_read_byte_data(address: uint8, command: uint8): (uint8, uint8) = let
/*local: wa_0$0(level=0)global: wa_0$0(level=0), i2c_write_byte_data$54$0(level=0)local: global: */ATSextern()atstkind_t0ype(atstype_uint8)_057_home_057_mike_057_cypress_057_workspace_057_UsbI2cRegMode_057_SATS_057_smbus_056_sats__i2c_write_byte_data(atstkind_t0ype(atstype_uint8) arg0, atstkind_t0ype(atstype_uint8) arg1, atstkind_t0ype(atstype_uint8) arg2){extern uint8_t _057_home_057_mike_057_cypress_057_workspace_057_UsbI2cRegMode_057_SATS_057_smbus_056_sats__i2c_write_byte_data(uint8_t arg0, uint8_t arg1, uint8_t arg2);
uint8_t v = _057_home_057_mike_057_cypress_057_workspace_057_UsbI2cRegMode_057_SATS_057_smbus_056_sats__i2c_write_byte_data(0x00, 0x00, 0x00);
#define i2c_write_byte_data _057_home_057_mike_057_cypress_057_workspace_057_UsbI2cRegMode_057_SATS_057_smbus_056_sats__i2c_write_byte_datafun i2c_read_byte_data (uint8, uint8) : (uint8, uint8) = "ext#i2c_read_byte_data_c"fun i2c_write_byte_data (uint8, uint8, uint8) : uint8 = "ext#i2c_write_byte_data_c"fun i2c_read_word_data (uint8, uint8) : (uint8, uint16) = "ext#i2c_read_word_data_c"fun i2c_write_word_data (uint8, uint8, uint16) : uint8 = "ext#i2c_write_word_data_c"--
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/4d58850c-9d05-4dea-bbe4-1c16a8e8bcaf%40googlegroups.com.
%{^uint8_t i2c_data[256];%}
macdef i2c_data = $extval(arrayref(uint8, 256),"i2c_data")
fun i2c_read_byte_data (uint8, uint8) : (uint8, uint8) = "ext#i2c_read_byte_data_c"implement i2c_read_byte(address: uint8): (uint8, uint8) = let var err: uint8 = err (0, u8) val () = ifnerr(i2c_start(), err, 1, u8) val () = ifnerr(i2c_write(wa address), err, 2, u8) val () = ifnerr(i2c_repeated_start(), err, 3, u8) val () = ifnerr(i2c_read(), err, 4, u8) val () = ifnerr(i2c_stop(i2c_data), err, 5, u8) in (err, i2c_data[0]) enduint8_t i2c_stop(uint8_t *data){ CyU3PReturnStatus_t status = CY_U3P_SUCCESS;
CyU3PDebugPrint (2, "I2C Stop\r\n");
if (read) { status = CyU3PI2cReceiveBytes (&shared_preamble, shared_data, shared_data_len, 0); memcpy(data, shared_data, shared_data_len); } else { if (shared_data_len == 0) shared_data[shared_data_len++] = shared_preamble.buffer[--shared_preamble.length]; status = CyU3PI2cTransmitBytes (&shared_preamble, shared_data, shared_data_len, 0); }
return((uint8_t)status);}typedef
struct {
uint8_t err;
uint16_t byte;
} err_byte;
extern err_byte i2c_read_byte_data_c(uint8_t, uint8_t);
err_byte sb;
uint8_t b;
sb = i2c_read_byte_data_c(0x30, 0x00);
status = sb.err;
b = sb.byte;
#pragma pack(push, 1)
typedef
struct {
uint8_t err;
uint16_t word;
} err_word;
#pragma pack(pop)