/* * JR-IDE Project * - (c) 2017 Alan Hightower * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef __MACHXO2_API_H__ #define __MACHXO2_API_H__ #include typedef enum { XO2_SECTOR_CFG, XO2_SECTOR_UFM } XO2_SECTOR_MODE; #define XO2_MODE_OFFLINE 0x0000 #define XO2_MODE_TRANSPARENT 0x0010 #define XO2_MODE_PROGRAM_FEATROW 0x0200 #define XO2_MODE_PROGRAM_CONFIG 0x0400 #define XO2_MODE_PROGRAM_UFM 0x0800 #define XO2_MODE_VERIFY_FEATROW 0x2000 #define XO2_MODE_VERIFY_CONFIG 0x4000 #define XO2_MODE_VERIFY_UFM 0x8000 // rest from TN1246 #define XO2_MODE_ERASE_SRAM 0x0001 // offline only #define XO2_MODE_ERASE_FEATROW 0x0002 #define XO2_MODE_ERASE_CONFIG 0x0004 #define XO2_MODE_ERASE_UFM 0x0008 typedef struct _st_xo2_handle xo2_handle_t; typedef int (*xo2_exchange_cb) (void *ctx, uint8_t *out, uint8_t out_len, uint8_t *in, uint8_t in_len); extern xo2_handle_t *xo2_open (xo2_exchange_cb cb, void *user_ctx); extern const char *xo2_name (xo2_handle_t *xo2); extern int xo2_read_device_id (xo2_handle_t *xo2, uint32_t *value); extern int xo2_read_user_code (xo2_handle_t *xo2, uint32_t *value); extern int xo2_read_trace_id (xo2_handle_t *xo2, uint8_t *value); extern int xo2_status_read (xo2_handle_t *xo2, uint32_t *value); extern int xo2_status_wait (xo2_handle_t *xo2, int timeout_ms); extern int xo2_mode_set (xo2_handle_t *xo2, int mode); extern int xo2_page_reset (xo2_handle_t *xo2, XO2_SECTOR_MODE mode); extern int xo2_page_set (xo2_handle_t *xo2, XO2_SECTOR_MODE mode, int page); extern int xo2_page_read (xo2_handle_t *xo2, XO2_SECTOR_MODE mode, uint8_t *data); extern int xo2_page_write (xo2_handle_t *xo2, XO2_SECTOR_MODE mode, uint8_t *data, int timeout_ms); extern int xo2_config_exit (xo2_handle_t *xo2); extern int xo2_refresh (xo2_handle_t *xo2); extern int xo2_done (xo2_handle_t *xo2, int timeout_ms); extern int xo2_flash_erase (xo2_handle_t *xo2, int mode); extern int xo2_factory_reset (xo2_handle_t *xo2); extern int xo2_feature_write (xo2_handle_t *xo2, const uint8_t *feature_row, const uint8_t *feature_bits); extern int xo2_feature_read (xo2_handle_t *xo2, uint8_t *feature_row, uint8_t *feature_bits); extern int xo2_program (xo2_handle_t *xo2, const void *image_ptr, int mode); extern uint32_t xo2_jpf_usercode (void *image_ptr); extern void xo2_close (xo2_handle_t *xo2); extern int xo2_file_info (const void *buffer, uint32_t *user_code, uint32_t *device_id); #endif