diff options
author | Leonard Kugis <leonard@kug.is> | 2024-05-15 20:00:51 +0200 |
---|---|---|
committer | Leonard Kugis <leonard@kug.is> | 2024-05-15 20:00:51 +0200 |
commit | 97cbb9d36288f624906ad6697d44677a105fe864 (patch) | |
tree | f1f2c883580e904edfc9652b866278e3fe218672 | |
parent | 82de9a951b1a43c4abc71425be03877a43063584 (diff) |
Implemented static and dynamic modes
-rw-r--r-- | FT245.c | 612 | ||||
-rw-r--r-- | FT245.h | 612 |
2 files changed, 952 insertions, 272 deletions
@@ -8,24 +8,16 @@ static void data_out(ft245_t *ft245); static void data_in(ft245_t *ft245); static void bit_set(ft245_t *ft245, uint8_t bit); static void bit_reset(ft245_t *ft245, uint8_t bit); +static bool full_word_enabled(ft245_t *ft245); +static bool read_byte(ft245_t *ft245, uint8_t byte, uint8_t *value); static bool tx_word(ft245_t *ft245); static bool rx_word(ft245_t *ft245); static atomic_flag lock = ATOMIC_FLAG_INIT; -void ft245_init(ft245_t *ft245) -{ - data_in(ft245); - - cb_init(ft245->buffer_rx, FT245_BUFFER_SIZE_RX); - cb_init(ft245->buffer_tx, FT245_BUFFER_SIZE_TX); - - ft245->clk_state = false; - ft245->clk_count = 0; -} - static void data_out(ft245_t *ft245) { +#if(FT245_DRIVER_MODE_DYNAMIC == 1) ft245->DATA0_to_output(); ft245->DATA1_to_output(); ft245->DATA2_to_output(); @@ -62,10 +54,50 @@ static void data_out(ft245_t *ft245) ft245->BE1_to_output(); ft245->BE2_to_output(); ft245->BE3_to_output(); +#endif // (FT245_DRIVER_MODE_DYNAMIC == 1) +#if(FT245_DRIVER_MODE_STATIC == 1) + FT245_DATA0_to_output(); + FT245_DATA1_to_output(); + FT245_DATA2_to_output(); + FT245_DATA3_to_output(); + FT245_DATA4_to_output(); + FT245_DATA5_to_output(); + FT245_DATA6_to_output(); + FT245_DATA7_to_output(); + FT245_DATA8_to_output(); + FT245_DATA9_to_output(); + FT245_DATA10_to_output(); + FT245_DATA11_to_output(); + FT245_DATA12_to_output(); + FT245_DATA13_to_output(); + FT245_DATA14_to_output(); + FT245_DATA15_to_output(); + FT245_DATA16_to_output(); + FT245_DATA17_to_output(); + FT245_DATA18_to_output(); + FT245_DATA19_to_output(); + FT245_DATA20_to_output(); + FT245_DATA21_to_output(); + FT245_DATA22_to_output(); + FT245_DATA23_to_output(); + FT245_DATA24_to_output(); + FT245_DATA25_to_output(); + FT245_DATA26_to_output(); + FT245_DATA27_to_output(); + FT245_DATA28_to_output(); + FT245_DATA29_to_output(); + FT245_DATA30_to_output(); + FT245_DATA31_to_output(); + FT245_BE0_to_output(); + FT245_BE1_to_output(); + FT245_BE2_to_output(); + FT245_BE3_to_output(); +#endif // (FT245_DRIVER_MODE_STATIC == 1) } static void data_in(ft245_t *ft245) { +#if(FT245_DRIVER_MODE_DYNAMIC == 1) ft245->DATA0_to_input(); ft245->DATA1_to_input(); ft245->DATA2_to_input(); @@ -102,10 +134,50 @@ static void data_in(ft245_t *ft245) ft245->BE1_to_input(); ft245->BE2_to_input(); ft245->BE3_to_input(); +#endif // (FT245_DRIVER_MODE_DYNAMIC == 1) +#if(FT245_DRIVER_MODE_STATIC == 1) + FT245_DATA0_to_input(); + FT245_DATA1_to_input(); + FT245_DATA2_to_input(); + FT245_DATA3_to_input(); + FT245_DATA4_to_input(); + FT245_DATA5_to_input(); + FT245_DATA6_to_input(); + FT245_DATA7_to_input(); + FT245_DATA8_to_input(); + FT245_DATA9_to_input(); + FT245_DATA10_to_input(); + FT245_DATA11_to_input(); + FT245_DATA12_to_input(); + FT245_DATA13_to_input(); + FT245_DATA14_to_input(); + FT245_DATA15_to_input(); + FT245_DATA16_to_input(); + FT245_DATA17_to_input(); + FT245_DATA18_to_input(); + FT245_DATA19_to_input(); + FT245_DATA20_to_input(); + FT245_DATA21_to_input(); + FT245_DATA22_to_input(); + FT245_DATA23_to_input(); + FT245_DATA24_to_input(); + FT245_DATA25_to_input(); + FT245_DATA26_to_input(); + FT245_DATA27_to_input(); + FT245_DATA28_to_input(); + FT245_DATA29_to_input(); + FT245_DATA30_to_input(); + FT245_DATA31_to_input(); + FT245_BE0_to_input(); + FT245_BE1_to_input(); + FT245_BE2_to_input(); + FT245_BE3_to_input(); +#endif // (FT245_DRIVER_MODE_STATIC == 1) } static void bit_set(ft245_t *ft245, uint8_t bit) { +#if(FT245_DRIVER_MODE_DYNAMIC == 1) switch(bit) { case 0: ft245->DATA0_set(); @@ -204,10 +276,112 @@ static void bit_set(ft245_t *ft245, uint8_t bit) ft245->DATA31_set(); break; } +#endif // (FT245_DRIVER_MODE_DYNAMIC == 1) +#if(FT245_DRIVER_MODE_STATIC == 1) + switch(bit) { + case 0: + FT245_DATA0_set(); + break; + case 1: + FT245_DATA1_set(); + break; + case 2: + FT245_DATA2_set(); + break; + case 3: + FT245_DATA3_set(); + break; + case 4: + FT245_DATA4_set(); + break; + case 5: + FT245_DATA5_set(); + break; + case 6: + FT245_DATA6_set(); + break; + case 7: + FT245_DATA7_set(); + break; + case 8: + FT245_DATA8_set(); + break; + case 9: + FT245_DATA9_set(); + break; + case 10: + FT245_DATA10_set(); + break; + case 11: + FT245_DATA11_set(); + break; + case 12: + FT245_DATA12_set(); + break; + case 13: + FT245_DATA13_set(); + break; + case 14: + FT245_DATA14_set(); + break; + case 15: + FT245_DATA15_set(); + break; + case 16: + FT245_DATA16_set(); + break; + case 17: + FT245_DATA17_set(); + break; + case 18: + FT245_DATA18_set(); + break; + case 19: + FT245_DATA19_set(); + break; + case 20: + FT245_DATA20_set(); + break; + case 21: + FT245_DATA21_set(); + break; + case 22: + FT245_DATA22_set(); + break; + case 23: + FT245_DATA23_set(); + break; + case 24: + FT245_DATA24_set(); + break; + case 25: + FT245_DATA25_set(); + break; + case 26: + FT245_DATA26_set(); + break; + case 27: + FT245_DATA27_set(); + break; + case 28: + FT245_DATA28_set(); + break; + case 29: + FT245_DATA29_set(); + break; + case 30: + FT245_DATA30_set(); + break; + case 31: + FT245_DATA31_set(); + break; + } +#endif // (FT245_DRIVER_MODE_STATIC == 1) } static void bit_reset(ft245_t *ft245, uint8_t bit) { +#if(FT245_DRIVER_MODE_DYNAMIC == 1) switch(bit) { case 0: ft245->DATA0_reset(); @@ -306,10 +480,112 @@ static void bit_reset(ft245_t *ft245, uint8_t bit) ft245->DATA31_reset(); break; } +#endif // (FT245_DRIVER_MODE_DYNAMIC == 1) +#if(FT245_DRIVER_MODE_STATIC == 1) + switch(bit) { + case 0: + FT245_DATA0_reset(); + break; + case 1: + FT245_DATA1_reset(); + break; + case 2: + FT245_DATA2_reset(); + break; + case 3: + FT245_DATA3_reset(); + break; + case 4: + FT245_DATA4_reset(); + break; + case 5: + FT245_DATA5_reset(); + break; + case 6: + FT245_DATA6_reset(); + break; + case 7: + FT245_DATA7_reset(); + break; + case 8: + FT245_DATA8_reset(); + break; + case 9: + FT245_DATA9_reset(); + break; + case 10: + FT245_DATA10_reset(); + break; + case 11: + FT245_DATA11_reset(); + break; + case 12: + FT245_DATA12_reset(); + break; + case 13: + FT245_DATA13_reset(); + break; + case 14: + FT245_DATA14_reset(); + break; + case 15: + FT245_DATA15_reset(); + break; + case 16: + FT245_DATA16_reset(); + break; + case 17: + FT245_DATA17_reset(); + break; + case 18: + FT245_DATA18_reset(); + break; + case 19: + FT245_DATA19_reset(); + break; + case 20: + FT245_DATA20_reset(); + break; + case 21: + FT245_DATA21_reset(); + break; + case 22: + FT245_DATA22_reset(); + break; + case 23: + FT245_DATA23_reset(); + break; + case 24: + FT245_DATA24_reset(); + break; + case 25: + FT245_DATA25_reset(); + break; + case 26: + FT245_DATA26_reset(); + break; + case 27: + FT245_DATA27_reset(); + break; + case 28: + FT245_DATA28_reset(); + break; + case 29: + FT245_DATA29_reset(); + break; + case 30: + FT245_DATA30_reset(); + break; + case 31: + FT245_DATA31_reset(); + break; + } +#endif // (FT245_DRIVER_MODE_STATIC == 1) } static bool byte_enabled_get(ft245_t *ft245, uint8_t byte) { +#if(FT245_DRIVER_MODE_DYNAMIC == 1) switch(byte) { case 0: ft245->BE0_to_input(); @@ -324,12 +600,30 @@ static bool byte_enabled_get(ft245_t *ft245, uint8_t byte) ft245->BE3_to_input(); return (ft245->BE3_read() != 0); } +#endif // (FT245_DRIVER_MODE_DYNAMIC == 1) +#if(FT245_DRIVER_MODE_STATIC == 1) + switch(byte) { + case 0: + FT245_BE0_to_input(); + return (FT245_BE0_read() != 0); + case 1: + FT245_BE1_to_input(); + return (FT245_BE1_read() != 0); + case 2: + FT245_BE2_to_input(); + return (FT245_BE2_read() != 0); + case 3: + FT245_BE3_to_input(); + return (FT245_BE3_read() != 0); + } +#endif // (FT245_DRIVER_MODE_STATIC == 1) return false; } static void byte_enabled_set(ft245_t *ft245, uint8_t byte, bool enabled) { +#if(FT245_DRIVER_MODE_DYNAMIC == 1) switch(byte) { case 0: ft245->BE0_to_output(); @@ -360,6 +654,181 @@ static void byte_enabled_set(ft245_t *ft245, uint8_t byte, bool enabled) ft245->BE3_reset(); break; } +#endif // (FT245_DRIVER_MODE_DYNAMIC == 1) +#if(FT245_DRIVER_MODE_STATIC == 1) + switch(byte) { + case 0: + FT245_BE0_to_output(); + if(enabled) + FT245_BE0_set(); + else + FT245_BE0_reset(); + break; + case 1: + FT245_BE1_to_output(); + if(enabled) + FT245_BE1_set(); + else + FT245_BE1_reset(); + break; + case 2: + FT245_BE2_to_output(); + if(enabled) + FT245_BE2_set(); + else + FT245_BE2_reset(); + break; + case 3: + FT245_BE3_to_output(); + if(enabled) + FT245_BE3_set(); + else + FT245_BE3_reset(); + break; + } +#endif // (FT245_DRIVER_MODE_STATIC == 1) +} + +static bool full_word_enabled(ft245_t *ft245) +{ +#if(FT245_DRIVER_MODE_DYNAMIC == 1) + return (ft245->BE3_read() && ft245->BE2_read() && ft245->BE1_read() && ft245->BE0_read()); +#endif // (FT245_DRIVER_MODE_DYNAMIC == 1) +#if(FT245_DRIVER_MODE_STATIC == 1) + return (FT245_BE3_read() && FT245_BE2_read() && FT245_BE1_read() && FT245_BE0_read()); +#endif // (FT245_DRIVER_MODE_STATIC == 1) +} + +static bool read_byte(ft245_t *ft245, uint8_t byte, uint8_t *value) +{ +#if(FT245_DRIVER_MODE_DYNAMIC == 1) + switch(byte) { + case 0: + if(ft245->BE0_read()) { + *value = ((((ft245->DATA7_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 7) | + (((ft245->DATA6_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 6) | + (((ft245->DATA5_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 5) | + (((ft245->DATA4_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 4) | + (((ft245->DATA3_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 3) | + (((ft245->DATA2_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 2) | + (((ft245->DATA1_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 1) | + (((ft245->DATA0_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 0)); + } else { + *value = 0; + return false; + } + return true; + case 1: + if(ft245->BE1_read()) { + *value = ((((ft245->DATA15_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 7) | + (((ft245->DATA14_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 6) | + (((ft245->DATA13_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 5) | + (((ft245->DATA12_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 4) | + (((ft245->DATA11_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 3) | + (((ft245->DATA10_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 2) | + (((ft245->DATA9_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 1) | + (((ft245->DATA8_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 0)); + } else { + *value = 0; + return false; + } + return true; + case 2: + if(ft245->BE2_read()) { + *value = ((((ft245->DATA23_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 7) | + (((ft245->DATA22_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 6) | + (((ft245->DATA21_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 5) | + (((ft245->DATA20_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 4) | + (((ft245->DATA19_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 3) | + (((ft245->DATA18_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 2) | + (((ft245->DATA17_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 1) | + (((ft245->DATA16_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 0)); + } else { + *value = 0; + return false; + } + return true; + case 3: + if(ft245->BE3_read()) { + *value = ((((ft245->DATA31_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 7) | + (((ft245->DATA30_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 6) | + (((ft245->DATA29_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 5) | + (((ft245->DATA28_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 4) | + (((ft245->DATA27_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 3) | + (((ft245->DATA26_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 2) | + (((ft245->DATA25_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 1) | + (((ft245->DATA24_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 0)); + } else { + *value = 0; + return false; + } + return true; + } +#endif // (FT245_DRIVER_MODE_DYNAMIC == 1) +#if(FT245_DRIVER_MODE_STATIC == 1) + switch(byte) { + case 0: + if(FT245_BE0_read()) { + *value = ((((FT245_DATA7_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 7) | + (((FT245_DATA6_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 6) | + (((FT245_DATA5_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 5) | + (((FT245_DATA4_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 4) | + (((FT245_DATA3_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 3) | + (((FT245_DATA2_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 2) | + (((FT245_DATA1_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 1) | + (((FT245_DATA0_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 0)); + } else { + *value = 0; + return false; + } + return true; + case 1: + if(FT245_BE1_read()) { + *value = ((((FT245_DATA15_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 7) | + (((FT245_DATA14_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 6) | + (((FT245_DATA13_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 5) | + (((FT245_DATA12_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 4) | + (((FT245_DATA11_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 3) | + (((FT245_DATA10_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 2) | + (((FT245_DATA9_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 1) | + (((FT245_DATA8_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 0)); + } else { + *value = 0; + return false; + } + return true; + case 2: + if(FT245_BE2_read()) { + *value = ((((FT245_DATA23_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 7) | + (((FT245_DATA22_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 6) | + (((FT245_DATA21_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 5) | + (((FT245_DATA20_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 4) | + (((FT245_DATA19_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 3) | + (((FT245_DATA18_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 2) | + (((FT245_DATA17_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 1) | + (((FT245_DATA16_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 0)); + } else { + *value = 0; + return false; + } + return true; + case 3: + if(FT245_BE3_read()) { + *value = ((((FT245_DATA31_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 7) | + (((FT245_DATA30_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 6) | + (((FT245_DATA29_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 5) | + (((FT245_DATA28_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 4) | + (((FT245_DATA27_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 3) | + (((FT245_DATA26_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 2) | + (((FT245_DATA25_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 1) | + (((FT245_DATA24_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 0)); + } else { + *value = 0; + return false; + } + return true; + } +#endif // (FT245_DRIVER_MODE_STATIC == 1) } static bool tx_word(ft245_t *ft245) @@ -403,70 +872,18 @@ static bool rx_word(ft245_t *ft245) if((cb_size(ft245->buffer_rx) - cb_occupation(ft245->buffer_rx)) < 4) return false; - if(ft245->full_word_mode && !(ft245->BE3_read() && ft245->BE2_read() && ft245->BE1_read() && ft245->BE0_read())) + if(ft245->full_word_mode && !full_word_enabled(ft245)) return false; uint8_t data[4]; - if(ft245->BE3_read()) { - data[3] = ((((ft245->DATA31_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 7) | - (((ft245->DATA30_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 6) | - (((ft245->DATA29_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 5) | - (((ft245->DATA28_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 4) | - (((ft245->DATA27_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 3) | - (((ft245->DATA26_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 2) | - (((ft245->DATA25_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 1) | - (((ft245->DATA24_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 0)); - cb_push(ft245->buffer_rx, data[3]); - } else { - data[3] = 0; - cb_push(ft245->buffer_rx, data[3]); - } - - if(ft245->BE2_read()) { - data[2] = ((((ft245->DATA23_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 7) | - (((ft245->DATA22_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 6) | - (((ft245->DATA21_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 5) | - (((ft245->DATA20_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 4) | - (((ft245->DATA19_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 3) | - (((ft245->DATA18_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 2) | - (((ft245->DATA17_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 1) | - (((ft245->DATA16_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 0)); - cb_push(ft245->buffer_rx, data[2]); - } else { - data[2] = 0; - cb_push(ft245->buffer_rx, data[2]); - } - - if(ft245->BE1_read()) { - data[1] = ((((ft245->DATA15_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 7) | - (((ft245->DATA14_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 6) | - (((ft245->DATA13_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 5) | - (((ft245->DATA12_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 4) | - (((ft245->DATA11_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 3) | - (((ft245->DATA10_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 2) | - (((ft245->DATA9_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 1) | - (((ft245->DATA8_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 0)); - cb_push(ft245->buffer_rx, data[1]); - } else { - data[1] = 0; - cb_push(ft245->buffer_rx, data[1]); - } + for(uint8_t i = 0; i < 4; i++) + read_byte(ft245, i, &data[i]); - if(ft245->BE0_read()) { - data[0] = ((((ft245->DATA7_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 7) | - (((ft245->DATA6_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 6) | - (((ft245->DATA5_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 5) | - (((ft245->DATA4_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 4) | - (((ft245->DATA3_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 3) | - (((ft245->DATA2_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 2) | - (((ft245->DATA1_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 1) | - (((ft245->DATA0_read() == 0) ? ((uint32_t) 0) : ((uint32_t) 1)) << 0)); - cb_push(ft245->buffer_rx, data[0]); - } else { - data[0] = 0; - cb_push(ft245->buffer_rx, data[0]); - } + cb_push(ft245->buffer_rx, data[3]); + cb_push(ft245->buffer_rx, data[2]); + cb_push(ft245->buffer_rx, data[1]); + cb_push(ft245->buffer_rx, data[0]); // Check for sync word 0x66665555 if((data[3] == 0x55) && (data[2] == 0x55) && (data[1] == 0x66) && (data[0] == 0x66)) @@ -475,6 +892,17 @@ static bool rx_word(ft245_t *ft245) return true; } +void ft245_init(ft245_t *ft245) +{ + data_in(ft245); + + cb_init(ft245->buffer_rx, FT245_BUFFER_SIZE_RX); + cb_init(ft245->buffer_tx, FT245_BUFFER_SIZE_TX); + + ft245->clk_state = false; + ft245->clk_count = 0; +} + void ft245_periodic(ft245_t *ft245) { static size_t oe_n = 0; @@ -483,6 +911,8 @@ void ft245_periodic(ft245_t *ft245) static size_t rst_n = 0; bool rxf_n = false; bool txe_n = false; + +#if(FT245_DRIVER_MODE_DYNAMIC == 1) if(ft245->clk_state) { ft245->CLK_reset(); ft245->clk_state = false; @@ -522,6 +952,48 @@ void ft245_periodic(ft245_t *ft245) data_in(ft245); } } +#endif // (FT245_DRIVER_MODE_DYNAMIC == 1) +#if(FT245_DRIVER_MODE_STATIC == 1) + if(ft245->clk_state) { + FT245_CLK_reset(); + ft245->clk_state = false; + } else { + FT245_CLK_set(); + ft245->clk_state = true; + + oe_n = FT245_OE_N_read() ? 0 : (oe_n + 1); + rd_n = FT245_RD_N_read() ? 0 : (rd_n + 1); + wr_n = FT245_WR_N_read() ? 0 : (wr_n + 1); + rst_n = FT245_RST_N_read() ? 0 : (rst_n + 1); + + if(rst_n) + return; + + rxf_n = (cb_occupation(ft245->buffer_tx) > (ft245->full_word_mode ? 3 : 0)); + txe_n = !cb_full(ft245->buffer_rx); + + if(rxf_n) + FT245_RXF_N_reset(); + else + FT245_RXF_N_set(); + + if(txe_n) + FT245_TXE_N_reset(); + else + FT245_TXE_N_set(); + + // OE_N low => Output Enable + // RD_N low => Read access for master + // Both required to drive data + if(rxf_n && oe_n && rd_n) { + tx_word(ft245); + } else if(txe_n && wr_n) { + rx_word(ft245); + } else { + data_in(ft245); + } + } +#endif // (FT245_DRIVER_MODE_STATIC == 1) } bool ft245_write_buffered(ft245_t *ft245, uint8_t *data, size_t size) @@ -6,6 +6,9 @@ #include <stdbool.h> #include "circular_buffer.h" +#define FT245_DRIVER_MODE_DYNAMIC 1 +#define FT245_DRIVER_MODE_STATIC 0 + #define FT245_BUFFER_SIZE_TX 64 #define FT245_BUFFER_SIZE_RX 64 @@ -21,215 +24,420 @@ typedef struct ft245 { // CLK state bool clk_state; uint8_t clk_count; +#if(FT245_DRIVER_MODE_DYNAMIC == 1) // To input - void (*const DATA0_to_input)(void); - void (*const DATA1_to_input)(void); - void (*const DATA2_to_input)(void); - void (*const DATA3_to_input)(void); - void (*const DATA4_to_input)(void); - void (*const DATA5_to_input)(void); - void (*const DATA6_to_input)(void); - void (*const DATA7_to_input)(void); - void (*const DATA8_to_input)(void); - void (*const DATA9_to_input)(void); - void (*const DATA10_to_input)(void); - void (*const DATA11_to_input)(void); - void (*const DATA12_to_input)(void); - void (*const DATA13_to_input)(void); - void (*const DATA14_to_input)(void); - void (*const DATA15_to_input)(void); - void (*const DATA16_to_input)(void); - void (*const DATA17_to_input)(void); - void (*const DATA18_to_input)(void); - void (*const DATA19_to_input)(void); - void (*const DATA20_to_input)(void); - void (*const DATA21_to_input)(void); - void (*const DATA22_to_input)(void); - void (*const DATA23_to_input)(void); - void (*const DATA24_to_input)(void); - void (*const DATA25_to_input)(void); - void (*const DATA26_to_input)(void); - void (*const DATA27_to_input)(void); - void (*const DATA28_to_input)(void); - void (*const DATA29_to_input)(void); - void (*const DATA30_to_input)(void); - void (*const DATA31_to_input)(void); - void (*const BE0_to_input)(void); - void (*const BE1_to_input)(void); - void (*const BE2_to_input)(void); - void (*const BE3_to_input)(void); + void (*DATA0_to_input)(void); + void (*DATA1_to_input)(void); + void (*DATA2_to_input)(void); + void (*DATA3_to_input)(void); + void (*DATA4_to_input)(void); + void (*DATA5_to_input)(void); + void (*DATA6_to_input)(void); + void (*DATA7_to_input)(void); + void (*DATA8_to_input)(void); + void (*DATA9_to_input)(void); + void (*DATA10_to_input)(void); + void (*DATA11_to_input)(void); + void (*DATA12_to_input)(void); + void (*DATA13_to_input)(void); + void (*DATA14_to_input)(void); + void (*DATA15_to_input)(void); + void (*DATA16_to_input)(void); + void (*DATA17_to_input)(void); + void (*DATA18_to_input)(void); + void (*DATA19_to_input)(void); + void (*DATA20_to_input)(void); + void (*DATA21_to_input)(void); + void (*DATA22_to_input)(void); + void (*DATA23_to_input)(void); + void (*DATA24_to_input)(void); + void (*DATA25_to_input)(void); + void (*DATA26_to_input)(void); + void (*DATA27_to_input)(void); + void (*DATA28_to_input)(void); + void (*DATA29_to_input)(void); + void (*DATA30_to_input)(void); + void (*DATA31_to_input)(void); + void (*BE0_to_input)(void); + void (*BE1_to_input)(void); + void (*BE2_to_input)(void); + void (*BE3_to_input)(void); // To output - void (*const DATA0_to_output)(void); - void (*const DATA1_to_output)(void); - void (*const DATA2_to_output)(void); - void (*const DATA3_to_output)(void); - void (*const DATA4_to_output)(void); - void (*const DATA5_to_output)(void); - void (*const DATA6_to_output)(void); - void (*const DATA7_to_output)(void); - void (*const DATA8_to_output)(void); - void (*const DATA9_to_output)(void); - void (*const DATA10_to_output)(void); - void (*const DATA11_to_output)(void); - void (*const DATA12_to_output)(void); - void (*const DATA13_to_output)(void); - void (*const DATA14_to_output)(void); - void (*const DATA15_to_output)(void); - void (*const DATA16_to_output)(void); - void (*const DATA17_to_output)(void); - void (*const DATA18_to_output)(void); - void (*const DATA19_to_output)(void); - void (*const DATA20_to_output)(void); - void (*const DATA21_to_output)(void); - void (*const DATA22_to_output)(void); - void (*const DATA23_to_output)(void); - void (*const DATA24_to_output)(void); - void (*const DATA25_to_output)(void); - void (*const DATA26_to_output)(void); - void (*const DATA27_to_output)(void); - void (*const DATA28_to_output)(void); - void (*const DATA29_to_output)(void); - void (*const DATA30_to_output)(void); - void (*const DATA31_to_output)(void); - void (*const BE0_to_output)(void); - void (*const BE1_to_output)(void); - void (*const BE2_to_output)(void); - void (*const BE3_to_output)(void); + void (*DATA0_to_output)(void); + void (*DATA1_to_output)(void); + void (*DATA2_to_output)(void); + void (*DATA3_to_output)(void); + void (*DATA4_to_output)(void); + void (*DATA5_to_output)(void); + void (*DATA6_to_output)(void); + void (*DATA7_to_output)(void); + void (*DATA8_to_output)(void); + void (*DATA9_to_output)(void); + void (*DATA10_to_output)(void); + void (*DATA11_to_output)(void); + void (*DATA12_to_output)(void); + void (*DATA13_to_output)(void); + void (*DATA14_to_output)(void); + void (*DATA15_to_output)(void); + void (*DATA16_to_output)(void); + void (*DATA17_to_output)(void); + void (*DATA18_to_output)(void); + void (*DATA19_to_output)(void); + void (*DATA20_to_output)(void); + void (*DATA21_to_output)(void); + void (*DATA22_to_output)(void); + void (*DATA23_to_output)(void); + void (*DATA24_to_output)(void); + void (*DATA25_to_output)(void); + void (*DATA26_to_output)(void); + void (*DATA27_to_output)(void); + void (*DATA28_to_output)(void); + void (*DATA29_to_output)(void); + void (*DATA30_to_output)(void); + void (*DATA31_to_output)(void); + void (*BE0_to_output)(void); + void (*BE1_to_output)(void); + void (*BE2_to_output)(void); + void (*BE3_to_output)(void); // Set - void (*const CLK_set)(void); - void (*const RXF_N_set)(void); - void (*const TXE_N_set)(void); - void (*const DATA0_set)(void); - void (*const DATA1_set)(void); - void (*const DATA2_set)(void); - void (*const DATA3_set)(void); - void (*const DATA4_set)(void); - void (*const DATA5_set)(void); - void (*const DATA6_set)(void); - void (*const DATA7_set)(void); - void (*const DATA8_set)(void); - void (*const DATA9_set)(void); - void (*const DATA10_set)(void); - void (*const DATA11_set)(void); - void (*const DATA12_set)(void); - void (*const DATA13_set)(void); - void (*const DATA14_set)(void); - void (*const DATA15_set)(void); - void (*const DATA16_set)(void); - void (*const DATA17_set)(void); - void (*const DATA18_set)(void); - void (*const DATA19_set)(void); - void (*const DATA20_set)(void); - void (*const DATA21_set)(void); - void (*const DATA22_set)(void); - void (*const DATA23_set)(void); - void (*const DATA24_set)(void); - void (*const DATA25_set)(void); - void (*const DATA26_set)(void); - void (*const DATA27_set)(void); - void (*const DATA28_set)(void); - void (*const DATA29_set)(void); - void (*const DATA30_set)(void); - void (*const DATA31_set)(void); - void (*const BE0_set)(void); - void (*const BE1_set)(void); - void (*const BE2_set)(void); - void (*const BE3_set)(void); + void (*CLK_set)(void); + void (*RXF_N_set)(void); + void (*TXE_N_set)(void); + void (*DATA0_set)(void); + void (*DATA1_set)(void); + void (*DATA2_set)(void); + void (*DATA3_set)(void); + void (*DATA4_set)(void); + void (*DATA5_set)(void); + void (*DATA6_set)(void); + void (*DATA7_set)(void); + void (*DATA8_set)(void); + void (*DATA9_set)(void); + void (*DATA10_set)(void); + void (*DATA11_set)(void); + void (*DATA12_set)(void); + void (*DATA13_set)(void); + void (*DATA14_set)(void); + void (*DATA15_set)(void); + void (*DATA16_set)(void); + void (*DATA17_set)(void); + void (*DATA18_set)(void); + void (*DATA19_set)(void); + void (*DATA20_set)(void); + void (*DATA21_set)(void); + void (*DATA22_set)(void); + void (*DATA23_set)(void); + void (*DATA24_set)(void); + void (*DATA25_set)(void); + void (*DATA26_set)(void); + void (*DATA27_set)(void); + void (*DATA28_set)(void); + void (*DATA29_set)(void); + void (*DATA30_set)(void); + void (*DATA31_set)(void); + void (*BE0_set)(void); + void (*BE1_set)(void); + void (*BE2_set)(void); + void (*BE3_set)(void); // Reset - void (*const CLK_reset)(void); - void (*const RXF_N_reset)(void); - void (*const TXE_N_reset)(void); - void (*const DATA0_reset)(void); - void (*const DATA1_reset)(void); - void (*const DATA2_reset)(void); - void (*const DATA3_reset)(void); - void (*const DATA4_reset)(void); - void (*const DATA5_reset)(void); - void (*const DATA6_reset)(void); - void (*const DATA7_reset)(void); - void (*const DATA8_reset)(void); - void (*const DATA9_reset)(void); - void (*const DATA10_reset)(void); - void (*const DATA11_reset)(void); - void (*const DATA12_reset)(void); - void (*const DATA13_reset)(void); - void (*const DATA14_reset)(void); - void (*const DATA15_reset)(void); - void (*const DATA16_reset)(void); - void (*const DATA17_reset)(void); - void (*const DATA18_reset)(void); - void (*const DATA19_reset)(void); - void (*const DATA20_reset)(void); - void (*const DATA21_reset)(void); - void (*const DATA22_reset)(void); - void (*const DATA23_reset)(void); - void (*const DATA24_reset)(void); - void (*const DATA25_reset)(void); - void (*const DATA26_reset)(void); - void (*const DATA27_reset)(void); - void (*const DATA28_reset)(void); - void (*const DATA29_reset)(void); - void (*const DATA30_reset)(void); - void (*const DATA31_reset)(void); - void (*const BE0_reset)(void); - void (*const BE1_reset)(void); - void (*const BE2_reset)(void); - void (*const BE3_reset)(void); + void (*CLK_reset)(void); + void (*RXF_N_reset)(void); + void (*TXE_N_reset)(void); + void (*DATA0_reset)(void); + void (*DATA1_reset)(void); + void (*DATA2_reset)(void); + void (*DATA3_reset)(void); + void (*DATA4_reset)(void); + void (*DATA5_reset)(void); + void (*DATA6_reset)(void); + void (*DATA7_reset)(void); + void (*DATA8_reset)(void); + void (*DATA9_reset)(void); + void (*DATA10_reset)(void); + void (*DATA11_reset)(void); + void (*DATA12_reset)(void); + void (*DATA13_reset)(void); + void (*DATA14_reset)(void); + void (*DATA15_reset)(void); + void (*DATA16_reset)(void); + void (*DATA17_reset)(void); + void (*DATA18_reset)(void); + void (*DATA19_reset)(void); + void (*DATA20_reset)(void); + void (*DATA21_reset)(void); + void (*DATA22_reset)(void); + void (*DATA23_reset)(void); + void (*DATA24_reset)(void); + void (*DATA25_reset)(void); + void (*DATA26_reset)(void); + void (*DATA27_reset)(void); + void (*DATA28_reset)(void); + void (*DATA29_reset)(void); + void (*DATA30_reset)(void); + void (*DATA31_reset)(void); + void (*BE0_reset)(void); + void (*BE1_reset)(void); + void (*BE2_reset)(void); + void (*BE3_reset)(void); // Toggle - void (*const CLK_toggle)(void); + void (*CLK_toggle)(void); // Read - uint32_t (*const TXE_N_read)(void); - uint32_t (*const RXF_N_read)(void); - uint32_t (*const WR_N_read)(void); - uint32_t (*const SIWU_N_read)(void); - uint32_t (*const RD_N_read)(void); - uint32_t (*const OE_N_read)(void); - uint32_t (*const RST_N_read)(void); - uint32_t (*const DATA0_read)(void); - uint32_t (*const DATA1_read)(void); - uint32_t (*const DATA2_read)(void); - uint32_t (*const DATA3_read)(void); - uint32_t (*const DATA4_read)(void); - uint32_t (*const DATA5_read)(void); - uint32_t (*const DATA6_read)(void); - uint32_t (*const DATA7_read)(void); - uint32_t (*const DATA8_read)(void); - uint32_t (*const DATA9_read)(void); - uint32_t (*const DATA10_read)(void); - uint32_t (*const DATA11_read)(void); - uint32_t (*const DATA12_read)(void); - uint32_t (*const DATA13_read)(void); - uint32_t (*const DATA14_read)(void); - uint32_t (*const DATA15_read)(void); - uint32_t (*const DATA16_read)(void); - uint32_t (*const DATA17_read)(void); - uint32_t (*const DATA18_read)(void); - uint32_t (*const DATA19_read)(void); - uint32_t (*const DATA20_read)(void); - uint32_t (*const DATA21_read)(void); - uint32_t (*const DATA22_read)(void); - uint32_t (*const DATA23_read)(void); - uint32_t (*const DATA24_read)(void); - uint32_t (*const DATA25_read)(void); - uint32_t (*const DATA26_read)(void); - uint32_t (*const DATA27_read)(void); - uint32_t (*const DATA28_read)(void); - uint32_t (*const DATA29_read)(void); - uint32_t (*const DATA30_read)(void); - uint32_t (*const DATA31_read)(void); - uint32_t (*const BE0_read)(void); - uint32_t (*const BE1_read)(void); - uint32_t (*const BE2_read)(void); - uint32_t (*const BE3_read)(void); + uint32_t (*TXE_N_read)(void); + uint32_t (*RXF_N_read)(void); + uint32_t (*WR_N_read)(void); + uint32_t (*SIWU_N_read)(void); + uint32_t (*RD_N_read)(void); + uint32_t (*OE_N_read)(void); + uint32_t (*RST_N_read)(void); + uint32_t (*DATA0_read)(void); + uint32_t (*DATA1_read)(void); + uint32_t (*DATA2_read)(void); + uint32_t (*DATA3_read)(void); + uint32_t (*DATA4_read)(void); + uint32_t (*DATA5_read)(void); + uint32_t (*DATA6_read)(void); + uint32_t (*DATA7_read)(void); + uint32_t (*DATA8_read)(void); + uint32_t (*DATA9_read)(void); + uint32_t (*DATA10_read)(void); + uint32_t (*DATA11_read)(void); + uint32_t (*DATA12_read)(void); + uint32_t (*DATA13_read)(void); + uint32_t (*DATA14_read)(void); + uint32_t (*DATA15_read)(void); + uint32_t (*DATA16_read)(void); + uint32_t (*DATA17_read)(void); + uint32_t (*DATA18_read)(void); + uint32_t (*DATA19_read)(void); + uint32_t (*DATA20_read)(void); + uint32_t (*DATA21_read)(void); + uint32_t (*DATA22_read)(void); + uint32_t (*DATA23_read)(void); + uint32_t (*DATA24_read)(void); + uint32_t (*DATA25_read)(void); + uint32_t (*DATA26_read)(void); + uint32_t (*DATA27_read)(void); + uint32_t (*DATA28_read)(void); + uint32_t (*DATA29_read)(void); + uint32_t (*DATA30_read)(void); + uint32_t (*DATA31_read)(void); + uint32_t (*BE0_read)(void); + uint32_t (*BE1_read)(void); + uint32_t (*BE2_read)(void); + uint32_t (*BE3_read)(void); +#endif // (FT245_DRIVER_MODE_DYNAMIC == 1) } ft245_t; -void ft245_init(ft245_t *ft245); -void ft245_periodic(ft245_t *ft245); -bool ft245_write_buffered(ft245_t *ft245, uint8_t *data, size_t size); -bool ft245_read_buffered(ft245_t *ft245, uint8_t *data, size_t size); -bool ft245_write_word_buffered(ft245_t *ft245, uint32_t word); -bool ft245_read_word_buffered(ft245_t *ft245, uint32_t *word); -size_t ft245_available_read(ft245_t *ft245); -size_t ft245_available_write(ft245_t *ft245); +#if(FT245_DRIVER_MODE_STATIC == 1) +// To input +extern void FT245_DATA0_to_input(void); +extern void FT245_DATA1_to_input(void); +extern void FT245_DATA2_to_input(void); +extern void FT245_DATA3_to_input(void); +extern void FT245_DATA4_to_input(void); +extern void FT245_DATA5_to_input(void); +extern void FT245_DATA6_to_input(void); +extern void FT245_DATA7_to_input(void); +extern void FT245_DATA8_to_input(void); +extern void FT245_DATA9_to_input(void); +extern void FT245_DATA10_to_input(void); +extern void FT245_DATA11_to_input(void); +extern void FT245_DATA12_to_input(void); +extern void FT245_DATA13_to_input(void); +extern void FT245_DATA14_to_input(void); +extern void FT245_DATA15_to_input(void); +extern void FT245_DATA16_to_input(void); +extern void FT245_DATA17_to_input(void); +extern void FT245_DATA18_to_input(void); +extern void FT245_DATA19_to_input(void); +extern void FT245_DATA20_to_input(void); +extern void FT245_DATA21_to_input(void); +extern void FT245_DATA22_to_input(void); +extern void FT245_DATA23_to_input(void); +extern void FT245_DATA24_to_input(void); +extern void FT245_DATA25_to_input(void); +extern void FT245_DATA26_to_input(void); +extern void FT245_DATA27_to_input(void); +extern void FT245_DATA28_to_input(void); +extern void FT245_DATA29_to_input(void); +extern void FT245_DATA30_to_input(void); +extern void FT245_DATA31_to_input(void); +extern void FT245_BE0_to_input(void); +extern void FT245_BE1_to_input(void); +extern void FT245_BE2_to_input(void); +extern void FT245_BE3_to_input(void); +// To output +extern void FT245_DATA0_to_output(void); +extern void FT245_DATA1_to_output(void); +extern void FT245_DATA2_to_output(void); +extern void FT245_DATA3_to_output(void); +extern void FT245_DATA4_to_output(void); +extern void FT245_DATA5_to_output(void); +extern void FT245_DATA6_to_output(void); +extern void FT245_DATA7_to_output(void); +extern void FT245_DATA8_to_output(void); +extern void FT245_DATA9_to_output(void); +extern void FT245_DATA10_to_output(void); +extern void FT245_DATA11_to_output(void); +extern void FT245_DATA12_to_output(void); +extern void FT245_DATA13_to_output(void); +extern void FT245_DATA14_to_output(void); +extern void FT245_DATA15_to_output(void); +extern void FT245_DATA16_to_output(void); +extern void FT245_DATA17_to_output(void); +extern void FT245_DATA18_to_output(void); +extern void FT245_DATA19_to_output(void); +extern void FT245_DATA20_to_output(void); +extern void FT245_DATA21_to_output(void); +extern void FT245_DATA22_to_output(void); +extern void FT245_DATA23_to_output(void); +extern void FT245_DATA24_to_output(void); +extern void FT245_DATA25_to_output(void); +extern void FT245_DATA26_to_output(void); +extern void FT245_DATA27_to_output(void); +extern void FT245_DATA28_to_output(void); +extern void FT245_DATA29_to_output(void); +extern void FT245_DATA30_to_output(void); +extern void FT245_DATA31_to_output(void); +extern void FT245_BE0_to_output(void); +extern void FT245_BE1_to_output(void); +extern void FT245_BE2_to_output(void); +extern void FT245_BE3_to_output(void); +// Set +extern void FT245_CLK_set(void); +extern void FT245_RXF_N_set(void); +extern void FT245_TXE_N_set(void); +extern void FT245_DATA0_set(void); +extern void FT245_DATA1_set(void); +extern void FT245_DATA2_set(void); +extern void FT245_DATA3_set(void); +extern void FT245_DATA4_set(void); +extern void FT245_DATA5_set(void); +extern void FT245_DATA6_set(void); +extern void FT245_DATA7_set(void); +extern void FT245_DATA8_set(void); +extern void FT245_DATA9_set(void); +extern void FT245_DATA10_set(void); +extern void FT245_DATA11_set(void); +extern void FT245_DATA12_set(void); +extern void FT245_DATA13_set(void); +extern void FT245_DATA14_set(void); +extern void FT245_DATA15_set(void); +extern void FT245_DATA16_set(void); +extern void FT245_DATA17_set(void); +extern void FT245_DATA18_set(void); +extern void FT245_DATA19_set(void); +extern void FT245_DATA20_set(void); +extern void FT245_DATA21_set(void); +extern void FT245_DATA22_set(void); +extern void FT245_DATA23_set(void); +extern void FT245_DATA24_set(void); +extern void FT245_DATA25_set(void); +extern void FT245_DATA26_set(void); +extern void FT245_DATA27_set(void); +extern void FT245_DATA28_set(void); +extern void FT245_DATA29_set(void); +extern void FT245_DATA30_set(void); +extern void FT245_DATA31_set(void); +extern void FT245_BE0_set(void); +extern void FT245_BE1_set(void); +extern void FT245_BE2_set(void); +extern void FT245_BE3_set(void); +// Reset +extern void FT245_CLK_reset(void); +extern void FT245_RXF_N_reset(void); +extern void FT245_TXE_N_reset(void); +extern void FT245_DATA0_reset(void); +extern void FT245_DATA1_reset(void); +extern void FT245_DATA2_reset(void); +extern void FT245_DATA3_reset(void); +extern void FT245_DATA4_reset(void); +extern void FT245_DATA5_reset(void); +extern void FT245_DATA6_reset(void); +extern void FT245_DATA7_reset(void); +extern void FT245_DATA8_reset(void); +extern void FT245_DATA9_reset(void); +extern void FT245_DATA10_reset(void); +extern void FT245_DATA11_reset(void); +extern void FT245_DATA12_reset(void); +extern void FT245_DATA13_reset(void); +extern void FT245_DATA14_reset(void); +extern void FT245_DATA15_reset(void); +extern void FT245_DATA16_reset(void); +extern void FT245_DATA17_reset(void); +extern void FT245_DATA18_reset(void); +extern void FT245_DATA19_reset(void); +extern void FT245_DATA20_reset(void); +extern void FT245_DATA21_reset(void); +extern void FT245_DATA22_reset(void); +extern void FT245_DATA23_reset(void); +extern void FT245_DATA24_reset(void); +extern void FT245_DATA25_reset(void); +extern void FT245_DATA26_reset(void); +extern void FT245_DATA27_reset(void); +extern void FT245_DATA28_reset(void); +extern void FT245_DATA29_reset(void); +extern void FT245_DATA30_reset(void); +extern void FT245_DATA31_reset(void); +extern void FT245_BE0_reset(void); +extern void FT245_BE1_reset(void); +extern void FT245_BE2_reset(void); +extern void FT245_BE3_reset(void); +// Toggle +extern void FT245_CLK_toggle(void); +// Read +extern uint32_t FT245_TXE_N_read(void); +extern uint32_t FT245_RXF_N_read(void); +extern uint32_t FT245_WR_N_read(void); +extern uint32_t FT245_SIWU_N_read(void); +extern uint32_t FT245_RD_N_read(void); +extern uint32_t FT245_OE_N_read(void); +extern uint32_t FT245_RST_N_read(void); +extern uint32_t FT245_DATA0_read(void); +extern uint32_t FT245_DATA1_read(void); +extern uint32_t FT245_DATA2_read(void); +extern uint32_t FT245_DATA3_read(void); +extern uint32_t FT245_DATA4_read(void); +extern uint32_t FT245_DATA5_read(void); +extern uint32_t FT245_DATA6_read(void); +extern uint32_t FT245_DATA7_read(void); +extern uint32_t FT245_DATA8_read(void); +extern uint32_t FT245_DATA9_read(void); +extern uint32_t FT245_DATA10_read(void); +extern uint32_t FT245_DATA11_read(void); +extern uint32_t FT245_DATA12_read(void); +extern uint32_t FT245_DATA13_read(void); +extern uint32_t FT245_DATA14_read(void); +extern uint32_t FT245_DATA15_read(void); +extern uint32_t FT245_DATA16_read(void); +extern uint32_t FT245_DATA17_read(void); +extern uint32_t FT245_DATA18_read(void); +extern uint32_t FT245_DATA19_read(void); +extern uint32_t FT245_DATA20_read(void); +extern uint32_t FT245_DATA21_read(void); +extern uint32_t FT245_DATA22_read(void); +extern uint32_t FT245_DATA23_read(void); +extern uint32_t FT245_DATA24_read(void); +extern uint32_t FT245_DATA25_read(void); +extern uint32_t FT245_DATA26_read(void); +extern uint32_t FT245_DATA27_read(void); +extern uint32_t FT245_DATA28_read(void); +extern uint32_t FT245_DATA29_read(void); +extern uint32_t FT245_DATA30_read(void); +extern uint32_t FT245_DATA31_read(void); +extern uint32_t FT245_BE0_read(void); +extern uint32_t FT245_BE1_read(void); +extern uint32_t FT245_BE2_read(void); +extern uint32_t FT245_BE3_read(void); +#endif + +void FT245_init(ft245_t *ft245); +void FT245_periodic(ft245_t *ft245); +bool FT245_write_buffered(ft245_t *ft245, uint8_t *data, size_t size); +bool FT245_read_buffered(ft245_t *ft245, uint8_t *data, size_t size); +bool FT245_write_word_buffered(ft245_t *ft245, uint32_t word); +bool FT245_read_word_buffered(ft245_t *ft245, uint32_t *word); +size_t FT245_available_read(ft245_t *ft245); +size_t FT245_available_write(ft245_t *ft245); #endif
\ No newline at end of file |