| 770 |
user890104 |
1 |
//
|
|
|
2 |
//
|
|
|
3 |
// Copyright 2011 user890104
|
|
|
4 |
//
|
|
|
5 |
//
|
|
|
6 |
// This file is part of emCORE.
|
|
|
7 |
//
|
|
|
8 |
// emCORE is free software: you can redistribute it and/or
|
|
|
9 |
// modify it under the terms of the GNU General Public License as
|
|
|
10 |
// published by the Free Software Foundation, either version 2 of the
|
|
|
11 |
// License, or (at your option) any later version.
|
|
|
12 |
//
|
|
|
13 |
// emCORE is distributed in the hope that it will be useful,
|
|
|
14 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
15 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
16 |
// See the GNU General Public License for more details.
|
|
|
17 |
//
|
|
|
18 |
// You should have received a copy of the GNU General Public License along
|
|
|
19 |
// with emCORE. If not, see <http://www.gnu.org/licenses/>.
|
|
|
20 |
//
|
|
|
21 |
//
|
|
|
22 |
|
|
|
23 |
|
|
|
24 |
#ifndef __EMCORE_H__
|
|
|
25 |
#define __EMCORE_H__
|
|
|
26 |
|
|
|
27 |
#include "global.h"
|
|
|
28 |
|
|
|
29 |
#define EMCORE_USB_VID 0xFFFF
|
|
|
30 |
#define EMCORE_USB_PID 0xE000
|
|
|
31 |
|
|
|
32 |
#define EMCORE_HEADER_SIZE 0x10
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
struct emcore_usb_endpoints_addr
|
|
|
36 |
{
|
|
|
37 |
uint8_t cout;
|
|
|
38 |
uint8_t cin;
|
|
|
39 |
uint8_t dout;
|
|
|
40 |
uint8_t din;
|
|
|
41 |
};
|
|
|
42 |
|
|
|
43 |
struct emcore_usb_endpoints_max_packet_size
|
|
|
44 |
{
|
|
|
45 |
uint16_t cout;
|
|
|
46 |
uint16_t cin;
|
|
|
47 |
uint32_t dout;
|
|
|
48 |
uint32_t din;
|
|
|
49 |
};
|
|
|
50 |
|
|
|
51 |
struct emcore_dev_info
|
|
|
52 |
{
|
|
|
53 |
uint32_t svn_revision;
|
|
|
54 |
uint8_t major, minor, patch, sw_type;
|
|
|
55 |
uint32_t hw_type;
|
|
|
56 |
};
|
|
|
57 |
|
|
|
58 |
struct emcore_user_mem_range
|
|
|
59 |
{
|
|
|
60 |
uint32_t lower;
|
|
|
61 |
uint32_t upper;
|
|
|
62 |
};
|
|
|
63 |
|
|
|
64 |
struct emcore_dir_entry
|
|
|
65 |
{
|
|
|
66 |
char* name;
|
|
|
67 |
uint32_t attributes;
|
|
|
68 |
uint32_t size;
|
|
|
69 |
uint32_t startcluster;
|
|
|
70 |
uint16_t wrtdate;
|
|
|
71 |
uint16_t wrttime;
|
|
|
72 |
};
|
|
|
73 |
|
|
|
74 |
enum emcore_error
|
|
|
75 |
{
|
|
|
76 |
EMCORE_SUCCESS,
|
|
|
77 |
EMCORE_ERROR_INVALID,
|
|
|
78 |
EMCORE_ERROR_NOT_SUPPORTED,
|
|
|
79 |
EMCORE_ERROR_BUSY,
|
|
|
80 |
EMCORE_ERROR_NO_DEVICE,
|
|
|
81 |
EMCORE_ERROR_INCOMPLETE,
|
|
|
82 |
EMCORE_ERROR_OVERFLOW,
|
|
|
83 |
EMCORE_ERROR_NOT_IMPLEMENTED,
|
|
|
84 |
EMCORE_ERROR_NO_MORE_ENTRIES,
|
|
|
85 |
EMCORE_ERROR_IO,
|
|
|
86 |
};
|
|
|
87 |
|
|
|
88 |
int emcore_cout(const void* data, const uint32_t length);
|
|
|
89 |
int emcore_cin(void* data, const uint32_t length);
|
|
|
90 |
int emcore_dout(const void* data, const uint32_t length);
|
|
|
91 |
int emcore_din(void* data, const uint32_t length);
|
|
|
92 |
|
|
|
93 |
int emcore_monitor_command(const void* out, void* in, const uint32_t send_length, const uint32_t receive_length);
|
|
|
94 |
|
|
|
95 |
int emcore_get_version(struct emcore_dev_info* dev_info);
|
|
|
96 |
int emcore_get_packet_info(struct emcore_usb_endpoints_max_packet_size* max_packet_size);
|
|
|
97 |
int emcore_get_user_mem_range(struct emcore_user_mem_range* mem_range);
|
|
|
98 |
int emcore_reset(const uint8_t graceful);
|
|
|
99 |
int emcore_poweroff(const uint8_t graceful);
|
|
|
100 |
int emcore_readmem(void* data, const uint32_t addr, const uint32_t size);
|
|
|
101 |
int emcore_writemem(const void* data, const uint32_t addr, const uint32_t size);
|
|
|
102 |
int emcore_readdma(void* data, const uint32_t addr, const uint32_t size);
|
|
|
103 |
int emcore_writedma(const void* data, const uint32_t addr, const uint32_t size);
|
|
|
104 |
int emcore_readi2c(void* data, const uint8_t bus, const uint8_t slave, const uint8_t addr, const uint8_t size);
|
|
|
105 |
int emcore_writei2c(const void* data, const uint8_t bus, const uint8_t slave, const uint8_t addr, const uint8_t size);
|
|
|
106 |
int emcore_file_open(uint32_t* handle, const char* pathname, const int flags);
|
|
|
107 |
int emcore_file_size(uint32_t* size, const uint32_t handle);
|
|
|
108 |
int emcore_file_read(uint32_t* nread, const uint32_t handle, const uint32_t addr, const uint32_t size);
|
| 784 |
user890104 |
109 |
int emcore_file_write(uint32_t* nwrite, const uint32_t handle, const uint32_t addr, const uint32_t size);
|
| 770 |
user890104 |
110 |
int emcore_file_seek(const uint32_t handle, const uint32_t offset, const uint32_t whence);
|
|
|
111 |
int emcore_file_truncate(const uint32_t handle, const uint32_t length);
|
|
|
112 |
int emcore_file_sync(const uint32_t handle);
|
|
|
113 |
int emcore_file_close(const uint32_t handle);
|
|
|
114 |
int emcore_file_close_all(uint32_t* count);
|
|
|
115 |
int emcore_file_kill_all(const uint32_t volume);
|
|
|
116 |
int emcore_file_unlink(const char* name);
|
|
|
117 |
int emcore_file_rename(const char* path, const char* newpath);
|
|
|
118 |
int emcore_dir_open(uint32_t* handle, const char* name);
|
|
|
119 |
int emcore_dir_read(struct emcore_dir_entry* entry, const uint32_t handle);
|
|
|
120 |
int emcore_dir_close(const uint32_t handle);
|
|
|
121 |
int emcore_dir_close_all(uint32_t* count);
|
| 782 |
user890104 |
122 |
int emcore_dir_create(const char* name);
|
|
|
123 |
int emcore_dir_remove(const char* name);
|
| 770 |
user890104 |
124 |
int emcore_errno(uint32_t* emcore_errno_value);
|
|
|
125 |
int emcore_malloc(uint32_t* ptr, const uint32_t size);
|
|
|
126 |
int emcore_memalign(uint32_t* ptr, const uint32_t align, const uint32_t size);
|
|
|
127 |
int emcore_realloc(uint32_t* new_ptr, const uint32_t ptr, const uint32_t size);
|
|
|
128 |
int emcore_reownalloc(const uint32_t ptr, const uint32_t owner);
|
|
|
129 |
int emcore_free(const uint32_t ptr);
|
|
|
130 |
int emcore_free_all(void);
|
|
|
131 |
|
|
|
132 |
int emcore_read(void* data, const uint32_t addr, const uint32_t size);
|
|
|
133 |
int emcore_write(const void* data, const uint32_t addr, const uint32_t size);
|
|
|
134 |
int emcore_ls(const uint32_t handle);
|
|
|
135 |
int emcore_test(void);
|
|
|
136 |
|
|
|
137 |
#endif /* __EMCORE_H__ */
|