Skip to content

Commit

Permalink
added support of H6 boards
Browse files Browse the repository at this point in the history
  • Loading branch information
Pako2 authored Nov 16, 2020
1 parent ee3084d commit 31d44d2
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 3 deletions.
45 changes: 45 additions & 0 deletions source/boards.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,51 @@ const int pin_to_gpio_zero[41] = {
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
};

/* OrangePi Lite 2 / One Plus H6 */
const int pin_to_gpio_lite2[41] =
{
-1, // 0

-1, -1, // 1, 2
230, -1,
229, -1,
228, 117,
-1, 118,
120, 73,
119, -1,
122, 72,
-1, 71,
66, -1,
67, 121,
64, 69,
-1, 227, // 25, 26

-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};

/* OrangePi Three H6 */
const int pin_to_gpio_three[41] =
{
-1, // 0

-1, -1, // 1, 2
122, -1,
121, -1,
118, 364,
-1, 355,
120, 114,
119, -1,
362, 111,
-1, 112,
229, -1,
230, 117,
228, 227,
-1, 360, // 25, 26

-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};


/* OrangePi Zero Plus 2 H3 */
const int pin_to_gpio_zero2[41] = {
-1, -1, -1, // 0, 1, 2
Expand Down
2 changes: 2 additions & 0 deletions source/boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const int pin_to_gpio_zero2[41];
const int pin_to_gpio_pc[41];
const int pin_to_gpio_pc2[41];
const int pin_to_gpio_prime[41];
const int pin_to_gpio_lite2[41];
const int pin_to_gpio_three[41];

const char* FUNCTIONS[41];

Expand Down
10 changes: 9 additions & 1 deletion source/c_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/


#ifdef FORCE_H6 //USE define_macros=[('FORCE_H6','1')] as argument in distutils.core.Extension !!!
#define GPIO_BASE_OPI (0x0300B000)
#define SUNXI_GPIO_BASE (0x0300B000)
#define SUNXI_PWM_BASE (0x0300A000)
#define MAP_SIZE (4096*1)
#else
#define GPIO_BASE_OPI (0x01C20000)
#define SUNXI_GPIO_BASE (0x01C20800)
#define SUNXI_PWM_BASE (0x01C21400)
#define MAP_SIZE (4096*2)
#endif

#define PAGE_SIZE (4*1024)
#define BLOCK_SIZE (4*1024)
#define MAP_SIZE (4096*2)
#define MAP_MASK (MAP_SIZE - 1)

#define SETUP_OK 0
Expand Down
1 change: 1 addition & 0 deletions source/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ int is_valid_raw_port(int channel)
if (channel >= 128 && channel < 147) return 5; // PE
if (channel >= 160 && channel < 167) return 6; // PF
if (channel >= 192 && channel < 207) return 7; // PG
if (channel >= 224 && channel < 256) return 8; // PH
if (channel >= 352 && channel < 365) return 12; // PL
return 0;
}
Expand Down
3 changes: 3 additions & 0 deletions source/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ SOFTWARE.
#define PLUS2E 4
#define PC2 5
#define PRIME 6
#define LITE2 7
#define ONEPLUS 7
#define THREE 8

#define MODE_UNKNOWN -1
#define BOARD 10
Expand Down
10 changes: 9 additions & 1 deletion source/constants.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,14 @@ void define_constants(PyObject *module)
bprime = Py_BuildValue("i", PRIME);
PyModule_AddObject(module, "PRIME", bprime);

version = Py_BuildValue("s", "0.6.3");
blite2 = Py_BuildValue("i", LITE2);
PyModule_AddObject(module, "LITE2", blite2);
PyModule_AddObject(module, "ONEPLUS", blite2);

bthree = Py_BuildValue("i", THREE);
PyModule_AddObject(module, "THREE", bthree);

version = Py_BuildValue("s", "0.6.3.1");
PyModule_AddObject(module, "VERSION", version);

PyModule_AddObject(module, "PA", Py_BuildValue("i", 0));
Expand All @@ -100,5 +107,6 @@ void define_constants(PyObject *module)
PyModule_AddObject(module, "PE", Py_BuildValue("i", 128));
PyModule_AddObject(module, "PF", Py_BuildValue("i", 160));
PyModule_AddObject(module, "PG", Py_BuildValue("i", 192));
PyModule_AddObject(module, "PH", Py_BuildValue("i", 224));
PyModule_AddObject(module, "PL", Py_BuildValue("i", 352));
}
2 changes: 2 additions & 0 deletions source/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@ PyObject *bzeroplus3;
PyObject *bpc;
PyObject *bpc2;
PyObject *bprime;
PyObject *blite2;
PyObject *bthree;

void define_constants(PyObject *module);
4 changes: 3 additions & 1 deletion source/py_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static PyObject *py_setopi(PyObject *self, PyObject *args)
return NULL;
}

if (board_type < ZERO || board_type > PRIME )
if (board_type < ZERO || board_type > THREE )
{
PyErr_SetString(PyExc_ValueError, "An invalid board was passed to setboard()");
return NULL;
Expand All @@ -89,6 +89,8 @@ static PyObject *py_setopi(PyObject *self, PyObject *args)
case 4 : pin_to_gpio = &pin_to_gpio_pc; break;
case 5 : pin_to_gpio = &pin_to_gpio_pc2; break;
case 6 : pin_to_gpio = &pin_to_gpio_prime; break;
case 7 : pin_to_gpio = &pin_to_gpio_lite2; break;
case 8 : pin_to_gpio = &pin_to_gpio_three; break;
}

Py_RETURN_NONE;
Expand Down

0 comments on commit 31d44d2

Please sign in to comment.