pyGPIO - A 'more general' python GPIO library


chwe
 Share

5 5

Recommended Posts

Hello, I am having a bit of an issue.

 

I have mapped my device (Bananapi M2Zero) into the 40pin template according to the schematics the provided here. 

https://drive.google.com/file/d/0B4PAo2nW2KfnMW5sVkxWSW9qa28/view

 

I then copied it and pasted the contents of that file into the existing bananapim2.h file.

After running setup.py install, my mapping.h file seems to match. 

 

Here is what I am using.

 

/*
 *
 * This file is part of pyA20.
 * mapping.h is python GPIO extension.
 *
 * Copyright (c) 2014 Stefan Mavrodiev @ OLIMEX LTD, <support@olimex.com>
 *
 * pyA20 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 2 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *
 * mapping.h from: https://github.com/wdmomoxx/orangepi_ZERO_gpio_pyH2
 *
 */

#ifndef __MAPPING_H
#define __MAPPING_H

#include "gpio_lib.h"

/**
Structure that describe all gpio
*/
typedef struct _pin {
	char name[10];          // The processor pin
	int offset;             // Memory offset for the pin
	int pin_number;         // Number on the connector
}pin_t;

typedef struct _gpio {
	char connector_name[10];
	pin_t pins[41];
}gpio_t;


gpio_t gpio[] = {

/*
Description of Pinheader, please don't change pinnumer to keep this library consistent! A 'RPi compatible'
pin header (40pin) looks like the following:

3.3V	|··|	5V
GPIO2	|··|	5V
GPIO3	|··|	GND
GPIO4	|··|	GPIO14
GND	|··|	GPIO15
GPIO17	|··|	GPIO18
GPIO27	|··|	GND
GPIO22	|··|	GPIO23
3.3V	|··|	GPIO24
GPIO10	|··|	GND
GPIO9	|··|	GPIO25
GPIO11	|··|	GPIO8
GND	|··|	GPIO7	
GPIO28*	|··|	GPIO29*
GPIO5	|··|	GND
GPIO6	|··|	GPIO12
GPIO13	|··|	GND
GPIO19	|··|	GPIO16
GPIO26	|··|	GPIO20
GND	|··|	GPIO21
(*) on the RPi those two pins are used for official HATS (read out eeprom), since this is never depoyed 
on SUNXI boards we can use this GPIOs too. ;)

replace XZ with the pin which is wired out on this position (e.g. PA10, PG11 etc.) 
*/  
	{"GPIO",
		{
			//'first row'
			{   "GPIO2",  SUNXI_GPA(12),  3   },
			{   "GPIO3",  SUNXI_GPA(11),  5   },
			{   "GPIO4",  SUNXI_GPA(6),  7   },
			{   "GPIO17",  SUNXI_GPA(1),  11   },
			{   "GPIO27",  SUNXI_GPA(0),  13   },
			{   "GPIO22",  SUNXI_GPA(3),  15   },
			{   "GPIO10",  SUNXI_GPC(0),  19  },
			{   "GPIO9",  SUNXI_GPC(1),  21  },
			{   "GPIO11",  SUNXI_GPC(2),  23  },
			{   "GPIO28",  SUNXI_GPA(19),  27   },
			{   "GPIO5",  SUNXI_GPA(7),  29   },
			{   "GPIO6",  SUNXI_GPA(8),  31  },
			{   "GPIO13",  SUNXI_GPA(9),  33  },
			{   "GPIO19",  SUNXI_GPA(10),  35  },
			{   "GPIO26",  SUNXI_GPA(17),  37  },			
			//'second row'
			{   "GPIO14",  SUNXI_GPA(13),  8  },	
			{   "GPIO15",  SUNXI_GPA(14),  10  },
			{   "GPIO18",  SUNXI_GPA(16),  12  },
			{   "GPIO23",  SUNXI_GPA(15),  16  },
			{   "GPIO24",  SUNXI_GPC(4),  18  },
			{   "GPIO25",  SUNXI_GPA(2),  22  },
			{   "GPIO8",  SUNXI_GPC(3),  24  },
			{   "GPIO7",  SUNXI_GPC(7),  26   },
			{   "GPIO29",  SUNXI_GPA(18),  28  },
			{   "GPIO12",  SUNXI_GPL(2),  32  },
			{   "GPIO16",  SUNXI_GPL(4),  36  },
			{   "GPIO20",  SUNXI_GPA(21),  38  },
			{   "GPIO21",  SUNXI_GPA(20),  40  },
			
			{
				{   0,  0,  0}
			},
		}
		},
  /*
    #define PIN_PG0		SUNXI_GPG(0)
*/
	{"LED",
		{
			{   "POWER_LED",  SUNXI_GPL(10),  1   },
			{   "STATUS_LED",  SUNXI_GPA(17),  2   },
			{
				{   0,  0,  0}
			},
		}
	},
};

#endif

 

The problem is that even though I think I have it mapped correctly, when I run blinkly.py which is sets GPIO4 high, GPIO25 is the one that is getting set high.

 

If anyone knows what I can do to correct this, or point me in the right direction. I would appreciate it. 

 

Link to post
Share on other sites

Donate and support the project!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

5 5