X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=bsb%2Ffirmware%2Finterface.h;h=3f8b42b47f1ded6a8b522fdbb9269673afd6faaa;hb=37082aba8175e02e86271010ee372d2f34fc6413;hp=a4f42406b9e86c056644bd8170eaf12d31e290eb;hpb=7af20f2577a732c8ff5c07fd60b8ba67e577f50e;p=home-hw.git diff --git a/bsb/firmware/interface.h b/bsb/firmware/interface.h index a4f4240..3f8b42b 100644 --- a/bsb/firmware/interface.h +++ b/bsb/firmware/interface.h @@ -15,11 +15,15 @@ * Vendor-defined request 0x00 sends struct bsb_stats in little endian. * * 0x01 = bulk endpoint - * Used for sending frames to BSB. + * Used for sending frames to BSB. Accepts BSB frames. CRC will be calculated + * automatically. * * 0x82 = interrupt endpoint - * Used for receiving frames from BSB. - * Also transmits 1-byte status reports on frames sent on endpoint 0x01. + * Used for receiving frames from BSB and status reports on sent frames. + * The first byte is a status byte (TX_RESULT_xxx), the rest is a frame. + * If status == TX_RESULT_NONE, the frame is a received frame. + * If status == TX_RESULT_OK, the frame is a received reply to the sent frame. + * Otherwise, the status indicates transmit error and the frame is empty. */ // Status sent on the interrupt endpoint @@ -51,20 +55,9 @@ enum bsb_tx_result { P(tx_rejects) \ P(tx_timeouts) \ P(tx_collisions) \ - P(tx_ok) - - u32 rx_noise; - u32 rx_errors; - u32 rx_invalid; - u32 rx_overruns; - u32 rx_timeouts; - u32 rx_bad_crc; - u32 rx_ok; - u32 tx_overruns; - u32 tx_rejects; - u32 tx_timeouts; - u32 tx_collisions; - u32 tx_ok; + P(tx_reply_timeouts) \ + P(tx_ok_no_reply) \ + P(tx_ok_replied) struct bsb_stats { #define P(x) u32 x; @@ -84,12 +77,21 @@ struct bsb_stats { * 16-bit CRC */ +// Positions of fields in a frame +enum bsb_frame { + BF_SOF, + BF_SRC, + BF_DEST, + BF_LEN, + BF_OP, +}; + enum bsb_address { BSB_ADDR_BOILER = 0, BSB_ADDR_EXT_BOARD = 3, BSB_ADDR_ROOM1 = 6, BSB_ADDR_ROOM2 = 7, - BSB_ADDR_GATEWAY = 0x42, + BSB_ADDR_GATEWAY = 0x42, // That's us BSB_ADDR_BROADCAST = 0x7f, };