BPI mapping tables created

This commit is contained in:
Tony Kuker 2022-10-29 20:57:59 -05:00
parent 8c1f6401b4
commit c71c2a2b7a
21 changed files with 1324 additions and 1739 deletions

View File

@ -120,6 +120,59 @@ bool GPIOBUS::Init(mode_e mode, board_type::rascsi_board_type_e rascsi_type)
return true;
}
// The GPIO hardware needs to be initialized before calling this function.
void GPIOBUS::InitializeGpio(){
// Set pull up/pull down
LOGTRACE("%s Set pull up/down....", __PRETTY_FUNCTION__);
board_type::gpio_pull_up_down_e pullmode ;
if (board->signal_control_mode == 0)
{
// #if SIGNAL_CONTROL_MODE == 0
LOGTRACE("%s GPIO_PULLNONE", __PRETTY_FUNCTION__);
pullmode = board_type::gpio_pull_up_down_e::GPIO_PULLNONE;
}
else if (board->signal_control_mode == 1)
{
// #elif SIGNAL_CONTROL_MODE == 1
LOGTRACE("%s GPIO_PULLUP", __PRETTY_FUNCTION__);
pullmode = board_type::gpio_pull_up_down_e ::GPIO_PULLUP;
}
else
{
// #else
LOGTRACE("%s GPIO_PULLDOWN", __PRETTY_FUNCTION__);
pullmode = board_type::gpio_pull_up_down_e ::GPIO_PULLDOWN;
}
// #endif
// Initialize all signals
LOGTRACE("%s Initialize all signals....", __PRETTY_FUNCTION__);
for (int i = 0; SignalTable[i] != board_type::pi_physical_pin_e::PI_PHYS_PIN_NONE; i++) {
board_type::pi_physical_pin_e j = SignalTable[i];
PinSetSignal(j, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinConfig(j, board_type::gpio_direction_e::GPIO_INPUT);
PullConfig(j, pullmode);
}
// Set control signals
LOGTRACE("%s Set control signals....", __PRETTY_FUNCTION__);
PinSetSignal(board->pin_act, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinSetSignal(board->pin_tad, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinSetSignal(board->pin_ind, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinSetSignal(board->pin_dtd, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinConfig(board->pin_act, board_type::gpio_direction_e::GPIO_OUTPUT);
PinConfig(board->pin_tad, board_type::gpio_direction_e::GPIO_OUTPUT);
PinConfig(board->pin_ind, board_type::gpio_direction_e::GPIO_OUTPUT);
PinConfig(board->pin_dtd, board_type::gpio_direction_e::GPIO_OUTPUT);
// Set the ENABLE signal
// This is used to show that the application is running
PinSetSignal(board->pin_enb, board->EnbOff());
PinConfig(board->pin_enb, board_type::gpio_direction_e::GPIO_OUTPUT);
}
void GPIOBUS::Cleanup()
{
#if defined(__x86_64__) || defined(__X86__)

View File

@ -265,6 +265,9 @@ class GPIOBUS : public BUS
// Destructor
bool Init(mode_e mode = mode_e::TARGET, board_type::rascsi_board_type_e rascsi_type =
board_type::rascsi_board_type_e::BOARD_TYPE_FULLSPEC) override;
void InitializeGpio();
// Initialization
void Reset() override;
// Reset

View File

@ -7,7 +7,7 @@
// Copyright (C) 2016-2020 GIMONS
//
// [ GPIO-SCSI bus ]
//
//https://github.com/BPI-SINOVOIP/RPi.GPIO/blob/master/source/bpi-m2p.h
//---------------------------------------------------------------------------
#include "hal/gpiobus_allwinner.h"

View File

@ -185,54 +185,55 @@ bool GPIOBUS_Raspberry::Init(mode_e mode, board_type::rascsi_board_type_e rascsi
// Set Drive Strength to 16mA
DrvConfig(7);
// Set pull up/pull down
LOGTRACE("%s Set pull up/down....", __PRETTY_FUNCTION__);
board_type::gpio_pull_up_down_e pullmode ;
if (board->signal_control_mode == 0)
{
// #if SIGNAL_CONTROL_MODE == 0
LOGTRACE("%s GPIO_PULLNONE", __PRETTY_FUNCTION__);
pullmode = board_type::gpio_pull_up_down_e::GPIO_PULLNONE;
}
else if (board->signal_control_mode == 1)
{
// #elif SIGNAL_CONTROL_MODE == 1
LOGTRACE("%s GPIO_PULLUP", __PRETTY_FUNCTION__);
pullmode = board_type::gpio_pull_up_down_e ::GPIO_PULLUP;
}
else
{
// #else
LOGTRACE("%s GPIO_PULLDOWN", __PRETTY_FUNCTION__);
pullmode = board_type::gpio_pull_up_down_e ::GPIO_PULLDOWN;
}
// #endif
GPIOBUS::InitializeGpio();
// // Set pull up/pull down
// LOGTRACE("%s Set pull up/down....", __PRETTY_FUNCTION__);
// board_type::gpio_pull_up_down_e pullmode ;
// if (board->signal_control_mode == 0)
// {
// // #if SIGNAL_CONTROL_MODE == 0
// LOGTRACE("%s GPIO_PULLNONE", __PRETTY_FUNCTION__);
// pullmode = board_type::gpio_pull_up_down_e::GPIO_PULLNONE;
// }
// else if (board->signal_control_mode == 1)
// {
// // #elif SIGNAL_CONTROL_MODE == 1
// LOGTRACE("%s GPIO_PULLUP", __PRETTY_FUNCTION__);
// pullmode = board_type::gpio_pull_up_down_e ::GPIO_PULLUP;
// }
// else
// {
// // #else
// LOGTRACE("%s GPIO_PULLDOWN", __PRETTY_FUNCTION__);
// pullmode = board_type::gpio_pull_up_down_e ::GPIO_PULLDOWN;
// }
// // #endif
// Initialize all signals
LOGTRACE("%s Initialize all signals....", __PRETTY_FUNCTION__);
// // Initialize all signals
// LOGTRACE("%s Initialize all signals....", __PRETTY_FUNCTION__);
for (int i = 0; SignalTable[i] != board_type::pi_physical_pin_e::PI_PHYS_PIN_NONE; i++) {
board_type::pi_physical_pin_e j = SignalTable[i];
PinSetSignal(j, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinConfig(j, board_type::gpio_direction_e::GPIO_INPUT);
PullConfig(j, pullmode);
}
// for (int i = 0; SignalTable[i] != board_type::pi_physical_pin_e::PI_PHYS_PIN_NONE; i++) {
// board_type::pi_physical_pin_e j = SignalTable[i];
// PinSetSignal(j, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// PinConfig(j, board_type::gpio_direction_e::GPIO_INPUT);
// PullConfig(j, pullmode);
// }
// Set control signals
LOGTRACE("%s Set control signals....", __PRETTY_FUNCTION__);
PinSetSignal(board->pin_act, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinSetSignal(board->pin_tad, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinSetSignal(board->pin_ind, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinSetSignal(board->pin_dtd, board_type::gpio_high_low_e::GPIO_STATE_LOW);
PinConfig(board->pin_act, board_type::gpio_direction_e::GPIO_OUTPUT);
PinConfig(board->pin_tad, board_type::gpio_direction_e::GPIO_OUTPUT);
PinConfig(board->pin_ind, board_type::gpio_direction_e::GPIO_OUTPUT);
PinConfig(board->pin_dtd, board_type::gpio_direction_e::GPIO_OUTPUT);
// // Set control signals
// LOGTRACE("%s Set control signals....", __PRETTY_FUNCTION__);
// PinSetSignal(board->pin_act, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// PinSetSignal(board->pin_tad, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// PinSetSignal(board->pin_ind, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// PinSetSignal(board->pin_dtd, board_type::gpio_high_low_e::GPIO_STATE_LOW);
// PinConfig(board->pin_act, board_type::gpio_direction_e::GPIO_OUTPUT);
// PinConfig(board->pin_tad, board_type::gpio_direction_e::GPIO_OUTPUT);
// PinConfig(board->pin_ind, board_type::gpio_direction_e::GPIO_OUTPUT);
// PinConfig(board->pin_dtd, board_type::gpio_direction_e::GPIO_OUTPUT);
// Set the ENABLE signal
// This is used to show that the application is running
PinSetSignal(board->pin_enb, board->EnbOff());
PinConfig(board->pin_enb, board_type::gpio_direction_e::GPIO_OUTPUT);
// // Set the ENABLE signal
// // This is used to show that the application is running
// PinSetSignal(board->pin_enb, board->EnbOff());
// PinConfig(board->pin_enb, board_type::gpio_direction_e::GPIO_OUTPUT);
// GPFSEL backup
LOGTRACE("%s GPFSEL backup....", __PRETTY_FUNCTION__);

File diff suppressed because it is too large Load Diff

109
cpp/hal/pi_defs/bpi-m1-m1p-r1.cpp Executable file
View File

@ -0,0 +1,109 @@
/*
Copyright (c) 2014-2017 Banana Pi
Updates Copyright (C) 2022 akuker
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "hal/pi_defs/bpi-gpio.h"
/* The following define the mapping of the Banana Pi CPU pins to the logical
* GPIO numbers. The GPIO numbers are used by the software to set/configure
* the CPU registers. */
#define BPI_M1P_01 -1
#define BPI_M1P_03 GPIO_PB21
#define BPI_M1P_05 GPIO_PB20
#define BPI_M1P_07 GPIO_PI03
#define BPI_M1P_09 -1
#define BPI_M1P_11 GPIO_PI19
#define BPI_M1P_13 GPIO_PI18
#define BPI_M1P_15 GPIO_PI17
#define BPI_M1P_17 -1
#define BPI_M1P_19 GPIO_PI12
#define BPI_M1P_21 GPIO_PI13
#define BPI_M1P_23 GPIO_PI11
#define BPI_M1P_25 -1
#define BPI_M1P_27 GPIO_PI01
#define BPI_M1P_29 GPIO_PB05
#define BPI_M1P_31 GPIO_PB06
#define BPI_M1P_33 GPIO_PB07
#define BPI_M1P_35 GPIO_PB08
#define BPI_M1P_37 GPIO_PB03
#define BPI_M1P_39 -1
#define BPI_M1P_02 -1
#define BPI_M1P_04 -1
#define BPI_M1P_06 -1
#define BPI_M1P_08 GPIO_PH00
#define BPI_M1P_10 GPIO_PH01
#define BPI_M1P_12 GPIO_PH02
#define BPI_M1P_14 -1
#define BPI_M1P_16 GPIO_PH20
#define BPI_M1P_18 GPIO_PH21
#define BPI_M1P_20 -1
#define BPI_M1P_22 GPIO_PI16
#define BPI_M1P_24 GPIO_PI10
#define BPI_M1P_26 GPIO_PI14
#define BPI_M1P_28 GPIO_PI00
#define BPI_M1P_30 -1
#define BPI_M1P_32 GPIO_PB12
#define BPI_M1P_34 -1
#define BPI_M1P_36 GPIO_PI21
#define BPI_M1P_38 GPIO_PI20
#define BPI_M1P_40 GPIO_PB13
const Banana_Pi_Gpio_Mapping banana_pi_m1_m1p_r1_map{
.phys_to_gpio_map =
{
{board_type::pi_physical_pin_e::PI_PHYS_PIN_03, BPI_M1P_03},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_05, BPI_M1P_05},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_07, BPI_M1P_07},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_08, BPI_M1P_08},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_10, BPI_M1P_10},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_11, BPI_M1P_11},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_12, BPI_M1P_12},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_13, BPI_M1P_13},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_15, BPI_M1P_15},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_16, BPI_M1P_16},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_18, BPI_M1P_18},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_19, BPI_M1P_19},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_21, BPI_M1P_21},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_22, BPI_M1P_22},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_23, BPI_M1P_23},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_24, BPI_M1P_24},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_26, BPI_M1P_26},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_27, BPI_M1P_27},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_28, BPI_M1P_28},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_29, BPI_M1P_29},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_31, BPI_M1P_31},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_32, BPI_M1P_32},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_33, BPI_M1P_33},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_35, BPI_M1P_35},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_36, BPI_M1P_36},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_37, BPI_M1P_37},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_38, BPI_M1P_38},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_40, BPI_M1P_40},
},
.I2C_DEV = "/dev/i2c-2",
.SPI_DEV = "/dev/spidev0.0",
.I2C_OFFSET = 2,
.SPI_OFFSET = 2,
.PWM_OFFSET = 2,
};

View File

@ -1,122 +0,0 @@
#define BPI_M1P_01 -1
#define BPI_M1P_03 GPIO_PB21
#define BPI_M1P_05 GPIO_PB20
#define BPI_M1P_07 GPIO_PI03
#define BPI_M1P_09 -1
#define BPI_M1P_11 GPIO_PI19
#define BPI_M1P_13 GPIO_PI18
#define BPI_M1P_15 GPIO_PI17
#define BPI_M1P_17 -1
#define BPI_M1P_19 GPIO_PI12
#define BPI_M1P_21 GPIO_PI13
#define BPI_M1P_23 GPIO_PI11
#define BPI_M1P_25 -1
#define BPI_M1P_27 GPIO_PI01
#define BPI_M1P_29 GPIO_PB05
#define BPI_M1P_31 GPIO_PB06
#define BPI_M1P_33 GPIO_PB07
#define BPI_M1P_35 GPIO_PB08
#define BPI_M1P_37 GPIO_PB03
#define BPI_M1P_39 -1
#define BPI_M1P_02 -1
#define BPI_M1P_04 -1
#define BPI_M1P_06 -1
#define BPI_M1P_08 GPIO_PH00
#define BPI_M1P_10 GPIO_PH01
#define BPI_M1P_12 GPIO_PH02
#define BPI_M1P_14 -1
#define BPI_M1P_16 GPIO_PH20
#define BPI_M1P_18 GPIO_PH21
#define BPI_M1P_20 -1
#define BPI_M1P_22 GPIO_PI16
#define BPI_M1P_24 GPIO_PI10
#define BPI_M1P_26 GPIO_PI14
#define BPI_M1P_28 GPIO_PI00
#define BPI_M1P_30 -1
#define BPI_M1P_32 GPIO_PB12
#define BPI_M1P_34 -1
#define BPI_M1P_36 GPIO_PI21
#define BPI_M1P_38 GPIO_PI20
#define BPI_M1P_40 GPIO_PB13
//map wpi gpio_num(index) to bp bpio_num(element)
int pinToGpio_BPI_M1P [64] =
{
BPI_M1P_11, BPI_M1P_12, //0, 1
BPI_M1P_13, BPI_M1P_15, //2, 3
BPI_M1P_16, BPI_M1P_18, //4, 5
BPI_M1P_22, BPI_M1P_07, //6, 7
BPI_M1P_03, BPI_M1P_05, //8, 9
BPI_M1P_24, BPI_M1P_26, //10, 11
BPI_M1P_19, BPI_M1P_21, //12, 13
BPI_M1P_23, BPI_M1P_08, //14, 15
BPI_M1P_10, -1, //16, 17
-1, -1, //18, 19
-1, BPI_M1P_29, //20, 21
BPI_M1P_31, BPI_M1P_33, //22, 23
BPI_M1P_35, BPI_M1P_37, //24, 25
BPI_M1P_32, BPI_M1P_36, //26, 27
BPI_M1P_38, BPI_M1P_40, //28. 29
BPI_M1P_27, BPI_M1P_28, //30, 31
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
} ;
//map bcm gpio_num(index) to bp gpio_num(element)
int pinTobcm_BPI_M1P [64] =
{
BPI_M1P_27, BPI_M1P_28, //0, 1
BPI_M1P_03, BPI_M1P_05, //2, 3
BPI_M1P_07, BPI_M1P_29, //4, 5
BPI_M1P_31, BPI_M1P_26, //6, 7
BPI_M1P_24, BPI_M1P_21, //8, 9
BPI_M1P_19, BPI_M1P_23, //10, 11
BPI_M1P_32, BPI_M1P_33, //12, 13
BPI_M1P_08, BPI_M1P_10, //14, 15
BPI_M1P_36, BPI_M1P_11, //16, 17
BPI_M1P_12, BPI_M1P_35, //18, 19
BPI_M1P_38, BPI_M1P_40, //20, 21
BPI_M1P_15, BPI_M1P_16, //22, 23
BPI_M1P_18, BPI_M1P_22, //24, 25
BPI_M1P_37, BPI_M1P_13, //26, 27
-1, -1,
-1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
} ;
//map phys_num(index) to bp gpio_num(element)
int physToGpio_BPI_M1P [64] =
{
-1, //0
-1, -1, //1, 2
BPI_M1P_03, -1, //3, 4
BPI_M1P_05, -1, //5, 6
BPI_M1P_07, BPI_M1P_08, //7, 8
-1, BPI_M1P_10, //9, 10
BPI_M1P_11, BPI_M1P_12, //11, 12
BPI_M1P_13, -1, //13, 14
BPI_M1P_15, BPI_M1P_16, //15, 16
-1, BPI_M1P_18, //17, 18
BPI_M1P_19, -1, //19, 20
BPI_M1P_21, BPI_M1P_22, //21, 22
BPI_M1P_23, BPI_M1P_24, //23, 24
-1, BPI_M1P_26, //25, 26
BPI_M1P_27, BPI_M1P_28, //27, 28
BPI_M1P_29, -1, //29, 30
BPI_M1P_31, BPI_M1P_32, //31, 32
BPI_M1P_33, -1, //33, 34
BPI_M1P_35, BPI_M1P_36, //35, 36
BPI_M1P_37, BPI_M1P_38, //37, 38
-1, BPI_M1P_40, //39, 40
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55
-1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63
} ;
#define M1P_I2C_DEV "/dev/i2c-2"
#define M1P_SPI_DEV "/dev/spidev0.0"
#define M1P_I2C_OFFSET 2
#define M1P_SPI_OFFSET 2
#define M1P_PWM_OFFSET 2

109
cpp/hal/pi_defs/bpi-m2.cpp Executable file
View File

@ -0,0 +1,109 @@
/*
Copyright (c) 2014-2017 Banana Pi
Updates Copyright (C) 2022 akuker
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "hal/pi_defs/bpi-gpio.h"
/* The following define the mapping of the Banana Pi CPU pins to the logical
* GPIO numbers. The GPIO numbers are used by the software to set/configure
* the CPU registers. */
#define BPI_M2_01 -1
#define BPI_M2_03 GPIO_PH19
#define BPI_M2_05 GPIO_PH18
#define BPI_M2_07 GPIO_PH09
#define BPI_M2_09 -1
#define BPI_M2_11 GPIO_PG07
#define BPI_M2_13 GPIO_PG06
#define BPI_M2_15 GPIO_PG09
#define BPI_M2_17 -1
#define BPI_M2_19 GPIO_PG15
#define BPI_M2_21 GPIO_PG16
#define BPI_M2_23 GPIO_PG14
#define BPI_M2_25 -1
#define BPI_M2_27 GPIO_PB06
#define BPI_M2_29 GPIO_PB00
#define BPI_M2_31 GPIO_PB01
#define BPI_M2_33 GPIO_PB02
#define BPI_M2_35 GPIO_PB03
#define BPI_M2_37 GPIO_PB04
#define BPI_M2_39 -1
#define BPI_M2_02 -1
#define BPI_M2_04 -1
#define BPI_M2_06 -1
#define BPI_M2_08 GPIO_PE04
#define BPI_M2_10 GPIO_PE05
#define BPI_M2_12 GPIO_PH10
#define BPI_M2_14 -1
#define BPI_M2_16 GPIO_PH11
#define BPI_M2_18 GPIO_PH12
#define BPI_M2_20 -1
#define BPI_M2_22 GPIO_PG08
#define BPI_M2_24 GPIO_PG13
#define BPI_M2_26 GPIO_PG12
#define BPI_M2_28 GPIO_PB05
#define BPI_M2_30 -1
#define BPI_M2_32 GPIO_PB07
#define BPI_M2_34 -1
#define BPI_M2_36 GPIO_PE06
#define BPI_M2_38 GPIO_PE07
#define BPI_M2_40 GPIO_PM02
const Banana_Pi_Gpio_Mapping banana_pi_m2_map{
.phys_to_gpio_map =
{
{board_type::pi_physical_pin_e::PI_PHYS_PIN_03, BPI_M2_03},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_05, BPI_M2_05},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_07, BPI_M2_07},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_08, BPI_M2_08},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_10, BPI_M2_10},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_11, BPI_M2_11},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_12, BPI_M2_12},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_13, BPI_M2_13},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_15, BPI_M2_15},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_16, BPI_M2_16},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_18, BPI_M2_18},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_19, BPI_M2_19},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_21, BPI_M2_21},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_22, BPI_M2_22},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_23, BPI_M2_23},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_24, BPI_M2_24},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_26, BPI_M2_26},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_27, BPI_M2_27},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_28, BPI_M2_28},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_29, BPI_M2_29},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_31, BPI_M2_31},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_32, BPI_M2_32},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_33, BPI_M2_33},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_35, BPI_M2_35},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_36, BPI_M2_36},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_37, BPI_M2_37},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_38, BPI_M2_38},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_40, BPI_M2_40},
},
.I2C_DEV = "/dev/i2c-2",
.SPI_DEV = "/dev/spidev0.0",
.I2C_OFFSET = 2,
.SPI_OFFSET = 2,
.PWM_OFFSET = 4,
};

View File

@ -1,122 +0,0 @@
#define BPI_M2_01 -1
#define BPI_M2_03 GPIO_PH19
#define BPI_M2_05 GPIO_PH18
#define BPI_M2_07 GPIO_PH09
#define BPI_M2_09 -1
#define BPI_M2_11 GPIO_PG07
#define BPI_M2_13 GPIO_PG06
#define BPI_M2_15 GPIO_PG09
#define BPI_M2_17 -1
#define BPI_M2_19 GPIO_PG15
#define BPI_M2_21 GPIO_PG16
#define BPI_M2_23 GPIO_PG14
#define BPI_M2_25 -1
#define BPI_M2_27 GPIO_PB06
#define BPI_M2_29 GPIO_PB00
#define BPI_M2_31 GPIO_PB01
#define BPI_M2_33 GPIO_PB02
#define BPI_M2_35 GPIO_PB03
#define BPI_M2_37 GPIO_PB04
#define BPI_M2_39 -1
#define BPI_M2_02 -1
#define BPI_M2_04 -1
#define BPI_M2_06 -1
#define BPI_M2_08 GPIO_PE04
#define BPI_M2_10 GPIO_PE05
#define BPI_M2_12 GPIO_PH10
#define BPI_M2_14 -1
#define BPI_M2_16 GPIO_PH11
#define BPI_M2_18 GPIO_PH12
#define BPI_M2_20 -1
#define BPI_M2_22 GPIO_PG08
#define BPI_M2_24 GPIO_PG13
#define BPI_M2_26 GPIO_PG12
#define BPI_M2_28 GPIO_PB05
#define BPI_M2_30 -1
#define BPI_M2_32 GPIO_PB07
#define BPI_M2_34 -1
#define BPI_M2_36 GPIO_PE06
#define BPI_M2_38 GPIO_PE07
#define BPI_M2_40 GPIO_PM02
//map wpi gpio_num(index) to bp bpio_num(element)
int pinToGpio_BPI_M2 [64] =
{
BPI_M2_11, BPI_M2_12, //0, 1
BPI_M2_13, BPI_M2_15, //2, 3
BPI_M2_16, BPI_M2_18, //4, 5
BPI_M2_22, BPI_M2_07, //6, 7
BPI_M2_03, BPI_M2_05, //8, 9
BPI_M2_24, BPI_M2_26, //10, 11
BPI_M2_19, BPI_M2_21, //12, 13
BPI_M2_23, BPI_M2_08, //14, 15
BPI_M2_10, -1, //16, 17
-1, -1, //18, 19
-1, BPI_M2_29, //20, 21
BPI_M2_31, BPI_M2_33, //22, 23
BPI_M2_35, BPI_M2_37, //24, 25
BPI_M2_32, BPI_M2_36, //26, 27
BPI_M2_38, BPI_M2_40, //28. 29
BPI_M2_27, BPI_M2_28, //30, 31
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
} ;
//map bcm gpio_num(index) to bp gpio_num(element)
int pinTobcm_BPI_M2 [64] =
{
BPI_M2_27, BPI_M2_28, //0, 1
BPI_M2_03, BPI_M2_05, //2, 3
BPI_M2_07, BPI_M2_29, //4, 5
BPI_M2_31, BPI_M2_26, //6, 7
BPI_M2_24, BPI_M2_21, //8, 9
BPI_M2_19, BPI_M2_23, //10, 11
BPI_M2_32, BPI_M2_33, //12, 13
BPI_M2_08, BPI_M2_10, //14, 15
BPI_M2_36, BPI_M2_11, //16, 17
BPI_M2_12, BPI_M2_35, //18, 19
BPI_M2_38, BPI_M2_40, //20, 21
BPI_M2_15, BPI_M2_16, //22, 23
BPI_M2_18, BPI_M2_22, //24, 25
BPI_M2_37, BPI_M2_13, //26, 27
-1, -1,
-1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
} ;
//map phys_num(index) to bp gpio_num(element)
int physToGpio_BPI_M2 [64] =
{
-1, //0
-1, -1, //1, 2
BPI_M2_03, -1, //3, 4
BPI_M2_05, -1, //5, 6
BPI_M2_07, BPI_M2_08, //7, 8
-1, BPI_M2_10, //9, 10
BPI_M2_11, BPI_M2_12, //11, 12
BPI_M2_13, -1, //13, 14
BPI_M2_15, BPI_M2_16, //15, 16
-1, BPI_M2_18, //17, 18
BPI_M2_19, -1, //19, 20
BPI_M2_21, BPI_M2_22, //21, 22
BPI_M2_23, BPI_M2_24, //23, 24
-1, BPI_M2_26, //25, 26
BPI_M2_27, BPI_M2_28, //27, 28
BPI_M2_29, -1, //29, 30
BPI_M2_31, BPI_M2_32, //31, 32
BPI_M2_33, -1, //33, 34
BPI_M2_35, BPI_M2_36, //35, 36
BPI_M2_37, BPI_M2_38, //37, 38
-1, BPI_M2_40, //39, 40
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55
-1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63
} ;
#define M2_I2C_DEV "/dev/i2c-2"
#define M2_SPI_DEV "/dev/spidev1.0"
#define M2_I2C_OFFSET 2
#define M2_SPI_OFFSET 2
#define M2_PWM_OFFSET 4

113
cpp/hal/pi_defs/bpi-m2m.cpp Executable file
View File

@ -0,0 +1,113 @@
/*
Copyright (c) 2014-2017 Banana Pi
Updates Copyright (C) 2022 akuker
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "hal/pi_defs/bpi-gpio.h"
/* The following define the mapping of the Banana Pi CPU pins to the logical
* GPIO numbers. The GPIO numbers are used by the software to set/configure
* the CPU registers. */
/* M2 Magic V1.2 20171023 */
#define BPI_M2M_01 -1
#define BPI_M2M_03 GPIO_PH05
#define BPI_M2M_05 GPIO_PH04
#define BPI_M2M_07 GPIO_PH01
#define BPI_M2M_09 -1
#define BPI_M2M_11 GPIO_PH06
#define BPI_M2M_13 GPIO_PH07
#define BPI_M2M_15 GPIO_PD21 // v1.1 GPIO_PG12
#define BPI_M2M_17 -1
#define BPI_M2M_19 GPIO_PC00
#define BPI_M2M_21 GPIO_PC01
#define BPI_M2M_23 GPIO_PC02
#define BPI_M2M_25 -1
#define BPI_M2M_27 GPIO_PD19
#define BPI_M2M_29 GPIO_PD18
#define BPI_M2M_31 GPIO_PD23 // v1.1 GPIO_PD21
#define BPI_M2M_33 GPIO_PD27 // v1.1 GPIO_PD20
#define BPI_M2M_35 GPIO_PG10 // v1.1 GPIO_PD25
#define BPI_M2M_37 GPIO_PL11 // v1.1 GPIO_PD24
#define BPI_M2M_39 -1
#define BPI_M2M_02 -1
#define BPI_M2M_04 -1
#define BPI_M2M_06 -1
#define BPI_M2M_08 GPIO_PB00
#define BPI_M2M_10 GPIO_PB01
//#define BPI_M2M_08 -1
//#define BPI_M2M_10 -1
#define BPI_M2M_12 GPIO_PG11 // v1.1 GPIO_PB03
#define BPI_M2M_14 -1
#define BPI_M2M_16 GPIO_PB02
#define BPI_M2M_18 GPIO_PB03 // v1.1 GPIO_PG11
#define BPI_M2M_20 -1
#define BPI_M2M_22 GPIO_PD20 // v1.1 GPIO_PG10
#define BPI_M2M_24 GPIO_PC03
#define BPI_M2M_26 GPIO_PD25 // v1.1 GPIO_PG13
#define BPI_M2M_28 GPIO_PD24 // v1.1 GPIO_PL11
#define BPI_M2M_30 -1
#define BPI_M2M_32 GPIO_PD22 // v1.1 GPIO_PD23
#define BPI_M2M_34 -1
#define BPI_M2M_36 GPIO_PD26 // v1.1 GPIO_PD22
#define BPI_M2M_38 GPIO_PG13 // v1.1 GPIO_PD27
#define BPI_M2M_40 GPIO_PG12 // v1.1 GPIO_PD26
const Banana_Pi_Gpio_Mapping banana_pi_m2m_map{
.phys_to_gpio_map =
{
{board_type::pi_physical_pin_e::PI_PHYS_PIN_03, BPI_M2M_03},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_05, BPI_M2M_05},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_07, BPI_M2M_07},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_08, BPI_M2M_08},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_10, BPI_M2M_10},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_11, BPI_M2M_11},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_12, BPI_M2M_12},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_13, BPI_M2M_13},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_15, BPI_M2M_15},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_16, BPI_M2M_16},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_18, BPI_M2M_18},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_19, BPI_M2M_19},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_21, BPI_M2M_21},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_22, BPI_M2M_22},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_23, BPI_M2M_23},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_24, BPI_M2M_24},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_26, BPI_M2M_26},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_27, BPI_M2M_27},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_28, BPI_M2M_28},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_29, BPI_M2M_29},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_31, BPI_M2M_31},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_32, BPI_M2M_32},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_33, BPI_M2M_33},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_35, BPI_M2M_35},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_36, BPI_M2M_36},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_37, BPI_M2M_37},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_38, BPI_M2M_38},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_40, BPI_M2M_40},
},
.I2C_DEV = "/dev/i2c-1",
.SPI_DEV = "/dev/spidev0.0",
.I2C_OFFSET = 2,
.SPI_OFFSET = 3,
.PWM_OFFSET = 2,
};

View File

@ -1,125 +0,0 @@
/* M2 Magic V1.2 20171023 */
#define BPI_M2M_01 -1
#define BPI_M2M_03 GPIO_PH05
#define BPI_M2M_05 GPIO_PH04
#define BPI_M2M_07 GPIO_PH01
#define BPI_M2M_09 -1
#define BPI_M2M_11 GPIO_PH06
#define BPI_M2M_13 GPIO_PH07
#define BPI_M2M_15 GPIO_PD21 // v1.1 GPIO_PG12
#define BPI_M2M_17 -1
#define BPI_M2M_19 GPIO_PC00
#define BPI_M2M_21 GPIO_PC01
#define BPI_M2M_23 GPIO_PC02
#define BPI_M2M_25 -1
#define BPI_M2M_27 GPIO_PD19
#define BPI_M2M_29 GPIO_PD18
#define BPI_M2M_31 GPIO_PD23 // v1.1 GPIO_PD21
#define BPI_M2M_33 GPIO_PD27 // v1.1 GPIO_PD20
#define BPI_M2M_35 GPIO_PG10 // v1.1 GPIO_PD25
#define BPI_M2M_37 GPIO_PL11 // v1.1 GPIO_PD24
#define BPI_M2M_39 -1
#define BPI_M2M_02 -1
#define BPI_M2M_04 -1
#define BPI_M2M_06 -1
#define BPI_M2M_08 GPIO_PB00
#define BPI_M2M_10 GPIO_PB01
//#define BPI_M2M_08 -1
//#define BPI_M2M_10 -1
#define BPI_M2M_12 GPIO_PG11 // v1.1 GPIO_PB03
#define BPI_M2M_14 -1
#define BPI_M2M_16 GPIO_PB02
#define BPI_M2M_18 GPIO_PB03 // v1.1 GPIO_PG11
#define BPI_M2M_20 -1
#define BPI_M2M_22 GPIO_PD20 // v1.1 GPIO_PG10
#define BPI_M2M_24 GPIO_PC03
#define BPI_M2M_26 GPIO_PD25 // v1.1 GPIO_PG13
#define BPI_M2M_28 GPIO_PD24 // v1.1 GPIO_PL11
#define BPI_M2M_30 -1
#define BPI_M2M_32 GPIO_PD22 // v1.1 GPIO_PD23
#define BPI_M2M_34 -1
#define BPI_M2M_36 GPIO_PD26 // v1.1 GPIO_PD22
#define BPI_M2M_38 GPIO_PG13 // v1.1 GPIO_PD27
#define BPI_M2M_40 GPIO_PG12 // v1.1 GPIO_PD26
//map wpi gpio_num(index) to bp bpio_num(element)
int pinToGpio_BPI_M2M [64] =
{
BPI_M2M_11, BPI_M2M_12, //0, 1
BPI_M2M_13, BPI_M2M_15, //2, 3
BPI_M2M_16, BPI_M2M_18, //4, 5
BPI_M2M_22, BPI_M2M_07, //6, 7
BPI_M2M_03, BPI_M2M_05, //8, 9
BPI_M2M_24, BPI_M2M_26, //10, 11
BPI_M2M_19, BPI_M2M_21, //12, 13
BPI_M2M_23, BPI_M2M_08, //14, 15
BPI_M2M_10, -1, //16, 17
-1, -1, //18, 19
-1, BPI_M2M_29, //20, 21
BPI_M2M_31, BPI_M2M_33, //22, 23
BPI_M2M_35, BPI_M2M_37, //24, 25
BPI_M2M_32, BPI_M2M_36, //26, 27
BPI_M2M_38, BPI_M2M_40, //28. 29
BPI_M2M_27, BPI_M2M_28, //30, 31
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
} ;
//map bcm gpio_num(index) to bp gpio_num(element)
int pinTobcm_BPI_M2M [64] =
{
BPI_M2M_27, BPI_M2M_28, //0, 1
BPI_M2M_03, BPI_M2M_05, //2, 3
BPI_M2M_07, BPI_M2M_29, //4, 5
BPI_M2M_31, BPI_M2M_26, //6, 7
BPI_M2M_24, BPI_M2M_21, //8, 9
BPI_M2M_19, BPI_M2M_23, //10, 11
BPI_M2M_32, BPI_M2M_33, //12, 13
BPI_M2M_08, BPI_M2M_10, //14, 15
BPI_M2M_36, BPI_M2M_11, //16, 17
BPI_M2M_12, BPI_M2M_35, //18, 19
BPI_M2M_38, BPI_M2M_40, //20, 21
BPI_M2M_15, BPI_M2M_16, //22, 23
BPI_M2M_18, BPI_M2M_22, //24, 25
BPI_M2M_37, BPI_M2M_13, //26, 27
-1, -1,
-1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
} ;
//map phys_num(index) to bp gpio_num(element)
int physToGpio_BPI_M2M [64] =
{
-1, //0
-1, -1, //1, 2
BPI_M2M_03, -1, //3, 4
BPI_M2M_05, -1, //5, 6
BPI_M2M_07, BPI_M2M_08, //7, 8
-1, BPI_M2M_10, //9, 10
BPI_M2M_11, BPI_M2M_12, //11, 12
BPI_M2M_13, -1, //13, 14
BPI_M2M_15, BPI_M2M_16, //15, 16
-1, BPI_M2M_18, //17, 18
BPI_M2M_19, -1, //19, 20
BPI_M2M_21, BPI_M2M_22, //21, 22
BPI_M2M_23, BPI_M2M_24, //23, 24
-1, BPI_M2M_26, //25, 26
BPI_M2M_27, BPI_M2M_28, //27, 28
BPI_M2M_29, -1, //29, 30
BPI_M2M_31, BPI_M2M_32, //31, 32
BPI_M2M_33, -1, //33, 34
BPI_M2M_35, BPI_M2M_36, //35, 36
BPI_M2M_37, BPI_M2M_38, //37, 38
-1, BPI_M2M_40, //39, 40
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55
-1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63
} ;
#define M2M_I2C_DEV "/dev/i2c-1"
#define M2M_SPI_DEV "/dev/spidev0.0"
#define M2M_I2C_OFFSET 2
#define M2M_SPI_OFFSET 3
#define M2M_PWM_OFFSET 2

View File

@ -1,124 +0,0 @@
#define BPI_M2M_01 -1
#define BPI_M2M_03 GPIO_PH05
#define BPI_M2M_05 GPIO_PH04
#define BPI_M2M_07 GPIO_PH01
#define BPI_M2M_09 -1
#define BPI_M2M_11 GPIO_PH06
#define BPI_M2M_13 GPIO_PH07
#define BPI_M2M_15 GPIO_PG12
#define BPI_M2M_17 -1
#define BPI_M2M_19 GPIO_PC00
#define BPI_M2M_21 GPIO_PC01
#define BPI_M2M_23 GPIO_PC02
#define BPI_M2M_25 -1
#define BPI_M2M_27 GPIO_PD19
#define BPI_M2M_29 GPIO_PD18
#define BPI_M2M_31 GPIO_PD21
#define BPI_M2M_33 GPIO_PD20
#define BPI_M2M_35 GPIO_PD25
#define BPI_M2M_37 GPIO_PD24
#define BPI_M2M_39 -1
#define BPI_M2M_02 -1
#define BPI_M2M_04 -1
#define BPI_M2M_06 -1
#define BPI_M2M_08 GPIO_PB00
#define BPI_M2M_10 GPIO_PB01
//#define BPI_M2M_08 -1
//#define BPI_M2M_10 -1
#define BPI_M2M_12 GPIO_PB03
#define BPI_M2M_14 -1
#define BPI_M2M_16 GPIO_PB02
#define BPI_M2M_18 GPIO_PG11
#define BPI_M2M_20 -1
#define BPI_M2M_22 GPIO_PG10
#define BPI_M2M_24 GPIO_PC03
#define BPI_M2M_26 GPIO_PG13
#define BPI_M2M_28 GPIO_PL11
#define BPI_M2M_30 -1
#define BPI_M2M_32 GPIO_PD23
#define BPI_M2M_34 -1
#define BPI_M2M_36 GPIO_PD22
#define BPI_M2M_38 GPIO_PD27
#define BPI_M2M_40 GPIO_PD26
//map wpi gpio_num(index) to bp bpio_num(element)
int pinToGpio_BPI_M2M [64] =
{
BPI_M2M_11, BPI_M2M_12, //0, 1
BPI_M2M_13, BPI_M2M_15, //2, 3
BPI_M2M_16, BPI_M2M_18, //4, 5
BPI_M2M_22, BPI_M2M_07, //6, 7
BPI_M2M_03, BPI_M2M_05, //8, 9
BPI_M2M_24, BPI_M2M_26, //10, 11
BPI_M2M_19, BPI_M2M_21, //12, 13
BPI_M2M_23, BPI_M2M_08, //14, 15
BPI_M2M_10, -1, //16, 17
-1, -1, //18, 19
-1, BPI_M2M_29, //20, 21
BPI_M2M_31, BPI_M2M_33, //22, 23
BPI_M2M_35, BPI_M2M_37, //24, 25
BPI_M2M_32, BPI_M2M_36, //26, 27
BPI_M2M_38, BPI_M2M_40, //28. 29
BPI_M2M_27, BPI_M2M_28, //30, 31
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
} ;
//map bcm gpio_num(index) to bp gpio_num(element)
int pinTobcm_BPI_M2M [64] =
{
BPI_M2M_27, BPI_M2M_28, //0, 1
BPI_M2M_03, BPI_M2M_05, //2, 3
BPI_M2M_07, BPI_M2M_29, //4, 5
BPI_M2M_31, BPI_M2M_26, //6, 7
BPI_M2M_24, BPI_M2M_21, //8, 9
BPI_M2M_19, BPI_M2M_23, //10, 11
BPI_M2M_32, BPI_M2M_33, //12, 13
BPI_M2M_08, BPI_M2M_10, //14, 15
BPI_M2M_36, BPI_M2M_11, //16, 17
BPI_M2M_12, BPI_M2M_35, //18, 19
BPI_M2M_38, BPI_M2M_40, //20, 21
BPI_M2M_15, BPI_M2M_16, //22, 23
BPI_M2M_18, BPI_M2M_22, //24, 25
BPI_M2M_37, BPI_M2M_13, //26, 27
-1, -1,
-1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
} ;
//map phys_num(index) to bp gpio_num(element)
int physToGpio_BPI_M2M [64] =
{
-1, //0
-1, -1, //1, 2
BPI_M2M_03, -1, //3, 4
BPI_M2M_05, -1, //5, 6
BPI_M2M_07, BPI_M2M_08, //7, 8
-1, BPI_M2M_10, //9, 10
BPI_M2M_11, BPI_M2M_12, //11, 12
BPI_M2M_13, -1, //13, 14
BPI_M2M_15, BPI_M2M_16, //15, 16
-1, BPI_M2M_18, //17, 18
BPI_M2M_19, -1, //19, 20
BPI_M2M_21, BPI_M2M_22, //21, 22
BPI_M2M_23, BPI_M2M_24, //23, 24
-1, BPI_M2M_26, //25, 26
BPI_M2M_27, BPI_M2M_28, //27, 28
BPI_M2M_29, -1, //29, 30
BPI_M2M_31, BPI_M2M_32, //31, 32
BPI_M2M_33, -1, //33, 34
BPI_M2M_35, BPI_M2M_36, //35, 36
BPI_M2M_37, BPI_M2M_38, //37, 38
-1, BPI_M2M_40, //39, 40
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55
-1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63
} ;
#define M2M_I2C_DEV "/dev/i2c-1"
#define M2M_SPI_DEV "/dev/spidev0.0"
#define M2M_I2C_OFFSET 2
#define M2M_SPI_OFFSET 3
#define M2M_PWM_OFFSET 2

112
cpp/hal/pi_defs/bpi-m2m_1p1.cpp Executable file
View File

@ -0,0 +1,112 @@
/*
Copyright (c) 2014-2017 Banana Pi
Updates Copyright (C) 2022 akuker
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "hal/pi_defs/bpi-gpio.h"
/* The following define the mapping of the Banana Pi CPU pins to the logical
* GPIO numbers. The GPIO numbers are used by the software to set/configure
* the CPU registers. */
#define BPI_M2M_01 -1
#define BPI_M2M_03 GPIO_PH05
#define BPI_M2M_05 GPIO_PH04
#define BPI_M2M_07 GPIO_PH01
#define BPI_M2M_09 -1
#define BPI_M2M_11 GPIO_PH06
#define BPI_M2M_13 GPIO_PH07
#define BPI_M2M_15 GPIO_PG12
#define BPI_M2M_17 -1
#define BPI_M2M_19 GPIO_PC00
#define BPI_M2M_21 GPIO_PC01
#define BPI_M2M_23 GPIO_PC02
#define BPI_M2M_25 -1
#define BPI_M2M_27 GPIO_PD19
#define BPI_M2M_29 GPIO_PD18
#define BPI_M2M_31 GPIO_PD21
#define BPI_M2M_33 GPIO_PD20
#define BPI_M2M_35 GPIO_PD25
#define BPI_M2M_37 GPIO_PD24
#define BPI_M2M_39 -1
#define BPI_M2M_02 -1
#define BPI_M2M_04 -1
#define BPI_M2M_06 -1
#define BPI_M2M_08 GPIO_PB00
#define BPI_M2M_10 GPIO_PB01
//#define BPI_M2M_08 -1
//#define BPI_M2M_10 -1
#define BPI_M2M_12 GPIO_PB03
#define BPI_M2M_14 -1
#define BPI_M2M_16 GPIO_PB02
#define BPI_M2M_18 GPIO_PG11
#define BPI_M2M_20 -1
#define BPI_M2M_22 GPIO_PG10
#define BPI_M2M_24 GPIO_PC03
#define BPI_M2M_26 GPIO_PG13
#define BPI_M2M_28 GPIO_PL11
#define BPI_M2M_30 -1
#define BPI_M2M_32 GPIO_PD23
#define BPI_M2M_34 -1
#define BPI_M2M_36 GPIO_PD22
#define BPI_M2M_38 GPIO_PD27
#define BPI_M2M_40 GPIO_PD26
const Banana_Pi_Gpio_Mapping banana_pi_m2m_1p1_map{
.phys_to_gpio_map =
{
{board_type::pi_physical_pin_e::PI_PHYS_PIN_03, BPI_M2M_03},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_05, BPI_M2M_05},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_07, BPI_M2M_07},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_08, BPI_M2M_08},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_10, BPI_M2M_10},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_11, BPI_M2M_11},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_12, BPI_M2M_12},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_13, BPI_M2M_13},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_15, BPI_M2M_15},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_16, BPI_M2M_16},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_18, BPI_M2M_18},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_19, BPI_M2M_19},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_21, BPI_M2M_21},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_22, BPI_M2M_22},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_23, BPI_M2M_23},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_24, BPI_M2M_24},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_26, BPI_M2M_26},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_27, BPI_M2M_27},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_28, BPI_M2M_28},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_29, BPI_M2M_29},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_31, BPI_M2M_31},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_32, BPI_M2M_32},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_33, BPI_M2M_33},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_35, BPI_M2M_35},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_36, BPI_M2M_36},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_37, BPI_M2M_37},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_38, BPI_M2M_38},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_40, BPI_M2M_40},
},
.I2C_DEV = "/dev/i2c-1",
.SPI_DEV = "/dev/spidev0.0",
.I2C_OFFSET = 2,
.SPI_OFFSET = 3,
.PWM_OFFSET = 2,
};

109
cpp/hal/pi_defs/bpi-m2p.cpp Executable file
View File

@ -0,0 +1,109 @@
/*
Copyright (c) 2014-2017 Banana Pi
Updates Copyright (C) 2022 akuker
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "hal/pi_defs/bpi-gpio.h"
/* The following define the mapping of the Banana Pi CPU pins to the logical
* GPIO numbers. The GPIO numbers are used by the software to set/configure
* the CPU registers. */
#define BPI_M2P_01 -1
#define BPI_M2P_03 GPIO_PA12
#define BPI_M2P_05 GPIO_PA11
#define BPI_M2P_07 GPIO_PA06
#define BPI_M2P_09 -1
#define BPI_M2P_11 GPIO_PA01
#define BPI_M2P_13 GPIO_PA00
#define BPI_M2P_15 GPIO_PA03
#define BPI_M2P_17 -1
#define BPI_M2P_19 GPIO_PC00
#define BPI_M2P_21 GPIO_PC01
#define BPI_M2P_23 GPIO_PC02
#define BPI_M2P_25 -1
#define BPI_M2P_27 GPIO_PA19
#define BPI_M2P_29 GPIO_PA07
#define BPI_M2P_31 GPIO_PA08
#define BPI_M2P_33 GPIO_PA09
#define BPI_M2P_35 GPIO_PA10
#define BPI_M2P_37 GPIO_PA17
#define BPI_M2P_39 -1
#define BPI_M2P_02 -1
#define BPI_M2P_04 -1
#define BPI_M2P_06 -1
#define BPI_M2P_08 GPIO_PA13
#define BPI_M2P_10 GPIO_PA14
#define BPI_M2P_12 GPIO_PA16
#define BPI_M2P_14 -1
#define BPI_M2P_16 GPIO_PA15
#define BPI_M2P_18 GPIO_PC04
#define BPI_M2P_20 -1
#define BPI_M2P_22 GPIO_PA02
#define BPI_M2P_24 GPIO_PC03
#define BPI_M2P_26 GPIO_PC07
#define BPI_M2P_28 GPIO_PA18
#define BPI_M2P_30 -1
#define BPI_M2P_32 GPIO_PL02
#define BPI_M2P_34 -1
#define BPI_M2P_36 GPIO_PL04
#define BPI_M2P_38 GPIO_PA21
#define BPI_M2P_40 GPIO_PA20
const Banana_Pi_Gpio_Mapping banana_pi_m2p_map{
.phys_to_gpio_map =
{
{board_type::pi_physical_pin_e::PI_PHYS_PIN_03, BPI_M2P_03},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_05, BPI_M2P_05},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_07, BPI_M2P_07},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_08, BPI_M2P_08},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_10, BPI_M2P_10},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_11, BPI_M2P_11},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_12, BPI_M2P_12},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_13, BPI_M2P_13},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_15, BPI_M2P_15},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_16, BPI_M2P_16},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_18, BPI_M2P_18},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_19, BPI_M2P_19},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_21, BPI_M2P_21},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_22, BPI_M2P_22},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_23, BPI_M2P_23},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_24, BPI_M2P_24},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_26, BPI_M2P_26},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_27, BPI_M2P_27},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_28, BPI_M2P_28},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_29, BPI_M2P_29},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_31, BPI_M2P_31},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_32, BPI_M2P_32},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_33, BPI_M2P_33},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_35, BPI_M2P_35},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_36, BPI_M2P_36},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_37, BPI_M2P_37},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_38, BPI_M2P_38},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_40, BPI_M2P_40},
},
.I2C_DEV = "/dev/i2c-0",
.SPI_DEV = "/dev/spidev0.0",
.I2C_OFFSET = 2,
.SPI_OFFSET = 3,
.PWM_OFFSET = 3,
};

View File

@ -1,122 +0,0 @@
#define BPI_M2P_01 -1
#define BPI_M2P_03 GPIO_PA12
#define BPI_M2P_05 GPIO_PA11
#define BPI_M2P_07 GPIO_PA06
#define BPI_M2P_09 -1
#define BPI_M2P_11 GPIO_PA01
#define BPI_M2P_13 GPIO_PA00
#define BPI_M2P_15 GPIO_PA03
#define BPI_M2P_17 -1
#define BPI_M2P_19 GPIO_PC00
#define BPI_M2P_21 GPIO_PC01
#define BPI_M2P_23 GPIO_PC02
#define BPI_M2P_25 -1
#define BPI_M2P_27 GPIO_PA19
#define BPI_M2P_29 GPIO_PA07
#define BPI_M2P_31 GPIO_PA08
#define BPI_M2P_33 GPIO_PA09
#define BPI_M2P_35 GPIO_PA10
#define BPI_M2P_37 GPIO_PA17
#define BPI_M2P_39 -1
#define BPI_M2P_02 -1
#define BPI_M2P_04 -1
#define BPI_M2P_06 -1
#define BPI_M2P_08 GPIO_PA13
#define BPI_M2P_10 GPIO_PA14
#define BPI_M2P_12 GPIO_PA16
#define BPI_M2P_14 -1
#define BPI_M2P_16 GPIO_PA15
#define BPI_M2P_18 GPIO_PC04
#define BPI_M2P_20 -1
#define BPI_M2P_22 GPIO_PA02
#define BPI_M2P_24 GPIO_PC03
#define BPI_M2P_26 GPIO_PC07
#define BPI_M2P_28 GPIO_PA18
#define BPI_M2P_30 -1
#define BPI_M2P_32 GPIO_PL02
#define BPI_M2P_34 -1
#define BPI_M2P_36 GPIO_PL04
#define BPI_M2P_38 GPIO_PA21
#define BPI_M2P_40 GPIO_PA20
//map wpi gpio_num(index) to bp bpio_num(element)
int pinToGpio_BPI_M2P [64] =
{
BPI_M2P_11, BPI_M2P_12, //0, 1
BPI_M2P_13, BPI_M2P_15, //2, 3
BPI_M2P_16, BPI_M2P_18, //4, 5
BPI_M2P_22, BPI_M2P_07, //6, 7
BPI_M2P_03, BPI_M2P_05, //8, 9
BPI_M2P_24, BPI_M2P_26, //10, 11
BPI_M2P_19, BPI_M2P_21, //12, 13
BPI_M2P_23, BPI_M2P_08, //14, 15
BPI_M2P_10, -1, //16, 17
-1, -1, //18, 19
-1, BPI_M2P_29, //20, 21
BPI_M2P_31, BPI_M2P_33, //22, 23
BPI_M2P_35, BPI_M2P_37, //24, 25
BPI_M2P_32, BPI_M2P_36, //26, 27
BPI_M2P_38, BPI_M2P_40, //28. 29
BPI_M2P_27, BPI_M2P_28, //30, 31
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
} ;
//map bcm gpio_num(index) to bp gpio_num(element)
int pinTobcm_BPI_M2P [64] =
{
BPI_M2P_27, BPI_M2P_28, //0, 1
BPI_M2P_03, BPI_M2P_05, //2, 3
BPI_M2P_07, BPI_M2P_29, //4, 5
BPI_M2P_31, BPI_M2P_26, //6, 7
BPI_M2P_24, BPI_M2P_21, //8, 9
BPI_M2P_19, BPI_M2P_23, //10, 11
BPI_M2P_32, BPI_M2P_33, //12, 13
BPI_M2P_08, BPI_M2P_10, //14, 15
BPI_M2P_36, BPI_M2P_11, //16, 17
BPI_M2P_12, BPI_M2P_35, //18, 19
BPI_M2P_38, BPI_M2P_40, //20, 21
BPI_M2P_15, BPI_M2P_16, //22, 23
BPI_M2P_18, BPI_M2P_22, //24, 25
BPI_M2P_37, BPI_M2P_13, //26, 27
-1, -1,
-1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
} ;
//map phys_num(index) to bp gpio_num(element)
int physToGpio_BPI_M2P [64] =
{
-1, //0
-1, -1, //1, 2
BPI_M2P_03, -1, //3, 4
BPI_M2P_05, -1, //5, 6
BPI_M2P_07, BPI_M2P_08, //7, 8
-1, BPI_M2P_10, //9, 10
BPI_M2P_11, BPI_M2P_12, //11, 12
BPI_M2P_13, -1, //13, 14
BPI_M2P_15, BPI_M2P_16, //15, 16
-1, BPI_M2P_18, //17, 18
BPI_M2P_19, -1, //19, 20
BPI_M2P_21, BPI_M2P_22, //21, 22
BPI_M2P_23, BPI_M2P_24, //23, 24
-1, BPI_M2P_26, //25, 26
BPI_M2P_27, BPI_M2P_28, //27, 28
BPI_M2P_29, -1, //29, 30
BPI_M2P_31, BPI_M2P_32, //31, 32
BPI_M2P_33, -1, //33, 34
BPI_M2P_35, BPI_M2P_36, //35, 36
BPI_M2P_37, BPI_M2P_38, //37, 38
-1, BPI_M2P_40, //39, 40
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55
-1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63
} ;
#define M2P_I2C_DEV "/dev/i2c-0"
#define M2P_SPI_DEV "/dev/spidev0.0"
#define M2P_I2C_OFFSET 2
#define M2P_SPI_OFFSET 3
#define M2P_PWM_OFFSET 3

109
cpp/hal/pi_defs/bpi-m2u.cpp Executable file
View File

@ -0,0 +1,109 @@
/*
Copyright (c) 2014-2017 Banana Pi
Updates Copyright (C) 2022 akuker
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "hal/pi_defs/bpi-gpio.h"
/* The following define the mapping of the Banana Pi CPU pins to the logical
* GPIO numbers. The GPIO numbers are used by the software to set/configure
* the CPU registers. */
#define BPI_M2U_01 -1
#define BPI_M2U_03 GPIO_PB21
#define BPI_M2U_05 GPIO_PB20
#define BPI_M2U_07 GPIO_PB03
#define BPI_M2U_09 -1
#define BPI_M2U_11 GPIO_PI20
#define BPI_M2U_13 GPIO_PI21
#define BPI_M2U_15 GPIO_PH25
#define BPI_M2U_17 -1
#define BPI_M2U_19 GPIO_PC00
#define BPI_M2U_21 GPIO_PC01
#define BPI_M2U_23 GPIO_PC02
#define BPI_M2U_25 -1
#define BPI_M2U_27 GPIO_PI01
#define BPI_M2U_29 GPIO_PH00
#define BPI_M2U_31 GPIO_PH01
#define BPI_M2U_33 GPIO_PH02
#define BPI_M2U_35 GPIO_PH03
#define BPI_M2U_37 GPIO_PH04
#define BPI_M2U_39 -1
#define BPI_M2U_02 -1
#define BPI_M2U_04 -1
#define BPI_M2U_06 -1
#define BPI_M2U_08 GPIO_PI18
#define BPI_M2U_10 GPIO_PI19
#define BPI_M2U_12 GPIO_PI17
#define BPI_M2U_14 -1
#define BPI_M2U_16 GPIO_PI16
#define BPI_M2U_18 GPIO_PH26
#define BPI_M2U_20 -1
#define BPI_M2U_22 GPIO_PH27
#define BPI_M2U_24 GPIO_PC23
#define BPI_M2U_26 GPIO_PH24
#define BPI_M2U_28 GPIO_PI00
#define BPI_M2U_30 -1
#define BPI_M2U_32 GPIO_PD20
#define BPI_M2U_34 -1
#define BPI_M2U_36 GPIO_PH07
#define BPI_M2U_38 GPIO_PH06
#define BPI_M2U_40 GPIO_PH05
const Banana_Pi_Gpio_Mapping banana_pi_m2u_map{
.phys_to_gpio_map =
{
{board_type::pi_physical_pin_e::PI_PHYS_PIN_03, BPI_M2U_03},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_05, BPI_M2U_05},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_07, BPI_M2U_07},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_08, BPI_M2U_08},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_10, BPI_M2U_10},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_11, BPI_M2U_11},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_12, BPI_M2U_12},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_13, BPI_M2U_13},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_15, BPI_M2U_15},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_16, BPI_M2U_16},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_18, BPI_M2U_18},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_19, BPI_M2U_19},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_21, BPI_M2U_21},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_22, BPI_M2U_22},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_23, BPI_M2U_23},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_24, BPI_M2U_24},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_26, BPI_M2U_26},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_27, BPI_M2U_27},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_28, BPI_M2U_28},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_29, BPI_M2U_29},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_31, BPI_M2U_31},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_32, BPI_M2U_32},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_33, BPI_M2U_33},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_35, BPI_M2U_35},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_36, BPI_M2U_36},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_37, BPI_M2U_37},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_38, BPI_M2U_38},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_40, BPI_M2U_40},
},
.I2C_DEV = "/dev/i2c-2",
.SPI_DEV = "/dev/spidev0.0",
.I2C_OFFSET = 2,
.SPI_OFFSET = 3,
.PWM_OFFSET = 3,
};

View File

@ -1,122 +0,0 @@
#define BPI_M2U_01 -1
#define BPI_M2U_03 GPIO_PB21
#define BPI_M2U_05 GPIO_PB20
#define BPI_M2U_07 GPIO_PB03
#define BPI_M2U_09 -1
#define BPI_M2U_11 GPIO_PI20
#define BPI_M2U_13 GPIO_PI21
#define BPI_M2U_15 GPIO_PH25
#define BPI_M2U_17 -1
#define BPI_M2U_19 GPIO_PC00
#define BPI_M2U_21 GPIO_PC01
#define BPI_M2U_23 GPIO_PC02
#define BPI_M2U_25 -1
#define BPI_M2U_27 GPIO_PI01
#define BPI_M2U_29 GPIO_PH00
#define BPI_M2U_31 GPIO_PH01
#define BPI_M2U_33 GPIO_PH02
#define BPI_M2U_35 GPIO_PH03
#define BPI_M2U_37 GPIO_PH04
#define BPI_M2U_39 -1
#define BPI_M2U_02 -1
#define BPI_M2U_04 -1
#define BPI_M2U_06 -1
#define BPI_M2U_08 GPIO_PI18
#define BPI_M2U_10 GPIO_PI19
#define BPI_M2U_12 GPIO_PI17
#define BPI_M2U_14 -1
#define BPI_M2U_16 GPIO_PI16
#define BPI_M2U_18 GPIO_PH26
#define BPI_M2U_20 -1
#define BPI_M2U_22 GPIO_PH27
#define BPI_M2U_24 GPIO_PC23
#define BPI_M2U_26 GPIO_PH24
#define BPI_M2U_28 GPIO_PI00
#define BPI_M2U_30 -1
#define BPI_M2U_32 GPIO_PD20
#define BPI_M2U_34 -1
#define BPI_M2U_36 GPIO_PH07
#define BPI_M2U_38 GPIO_PH06
#define BPI_M2U_40 GPIO_PH05
//map wpi gpio_num(index) to bp bpio_num(element)
int pinToGpio_BPI_M2U [64] =
{
BPI_M2U_11, BPI_M2U_12, //0, 1
BPI_M2U_13, BPI_M2U_15, //2, 3
BPI_M2U_16, BPI_M2U_18, //4, 5
BPI_M2U_22, BPI_M2U_07, //6, 7
BPI_M2U_03, BPI_M2U_05, //8, 9
BPI_M2U_24, BPI_M2U_26, //10, 11
BPI_M2U_19, BPI_M2U_21, //12, 13
BPI_M2U_23, BPI_M2U_08, //14, 15
BPI_M2U_10, -1, //16, 17
-1, -1, //18, 19
-1, BPI_M2U_29, //20, 21
BPI_M2U_31, BPI_M2U_33, //22, 23
BPI_M2U_35, BPI_M2U_37, //24, 25
BPI_M2U_32, BPI_M2U_36, //26, 27
BPI_M2U_38, BPI_M2U_40, //28. 29
BPI_M2U_27, BPI_M2U_28, //30, 31
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
} ;
//map bcm gpio_num(index) to bp gpio_num(element)
int pinTobcm_BPI_M2U [64] =
{
BPI_M2U_27, BPI_M2U_28, //0, 1
BPI_M2U_03, BPI_M2U_05, //2, 3
BPI_M2U_07, BPI_M2U_29, //4, 5
BPI_M2U_31, BPI_M2U_26, //6, 7
BPI_M2U_24, BPI_M2U_21, //8, 9
BPI_M2U_19, BPI_M2U_23, //10, 11
BPI_M2U_32, BPI_M2U_33, //12, 13
BPI_M2U_08, BPI_M2U_10, //14, 15
BPI_M2U_36, BPI_M2U_11, //16, 17
BPI_M2U_12, BPI_M2U_35, //18, 19
BPI_M2U_38, BPI_M2U_40, //20, 21
BPI_M2U_15, BPI_M2U_16, //22, 23
BPI_M2U_18, BPI_M2U_22, //24, 25
BPI_M2U_37, BPI_M2U_13, //26, 27
-1, -1,
-1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
} ;
//map phys_num(index) to bp gpio_num(element)
int physToGpio_BPI_M2U [64] =
{
-1, //0
-1, -1, //1, 2
BPI_M2U_03, -1, //3, 4
BPI_M2U_05, -1, //5, 6
BPI_M2U_07, BPI_M2U_08, //7, 8
-1, BPI_M2U_10, //9, 10
BPI_M2U_11, BPI_M2U_12, //11, 12
BPI_M2U_13, -1, //13, 14
BPI_M2U_15, BPI_M2U_16, //15, 16
-1, BPI_M2U_18, //17, 18
BPI_M2U_19, -1, //19, 20
BPI_M2U_21, BPI_M2U_22, //21, 22
BPI_M2U_23, BPI_M2U_24, //23, 24
-1, BPI_M2U_26, //25, 26
BPI_M2U_27, BPI_M2U_28, //27, 28
BPI_M2U_29, -1, //29, 30
BPI_M2U_31, BPI_M2U_32, //31, 32
BPI_M2U_33, -1, //33, 34
BPI_M2U_35, BPI_M2U_36, //35, 36
BPI_M2U_37, BPI_M2U_38, //37, 38
-1, BPI_M2U_40, //39, 40
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55
-1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63
} ;
#define M2U_I2C_DEV "/dev/i2c-2"
#define M2U_SPI_DEV "/dev/spidev0.0"
#define M2U_I2C_OFFSET 2
#define M2U_SPI_OFFSET 3
#define M2U_PWM_OFFSET 3

109
cpp/hal/pi_defs/bpi-m3.cpp Executable file
View File

@ -0,0 +1,109 @@
/*
Copyright (c) 2014-2017 Banana Pi
Updates Copyright (C) 2022 akuker
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "hal/pi_defs/bpi-gpio.h"
/* The following define the mapping of the Banana Pi CPU pins to the logical
* GPIO numbers. The GPIO numbers are used by the software to set/configure
* the CPU registers. */
#define BPI_M3_01 -1
#define BPI_M3_03 GPIO_PH05
#define BPI_M3_05 GPIO_PH04
#define BPI_M3_07 GPIO_PL10
#define BPI_M3_09 -1
#define BPI_M3_11 GPIO_PC04
#define BPI_M3_13 GPIO_PC07
#define BPI_M3_15 GPIO_PC17
#define BPI_M3_17 -1
#define BPI_M3_19 GPIO_PC00
#define BPI_M3_21 GPIO_PC01
#define BPI_M3_23 GPIO_PC02
#define BPI_M3_25 -1
#define BPI_M3_27 GPIO_PH03
#define BPI_M3_29 GPIO_PC18
#define BPI_M3_31 GPIO_PG10
#define BPI_M3_33 GPIO_PG11
#define BPI_M3_35 GPIO_PG12
#define BPI_M3_37 GPIO_PE04
#define BPI_M3_39 -1
#define BPI_M3_02 -1
#define BPI_M3_04 -1
#define BPI_M3_06 -1
#define BPI_M3_08 GPIO_PB00
#define BPI_M3_10 GPIO_PB01
#define BPI_M3_12 GPIO_PB03
#define BPI_M3_14 -1
#define BPI_M3_16 GPIO_PB02
#define BPI_M3_18 GPIO_PL08
#define BPI_M3_20 -1
#define BPI_M3_22 GPIO_PL09
#define BPI_M3_24 GPIO_PC03
#define BPI_M3_26 GPIO_PH10
#define BPI_M3_28 GPIO_PH02
#define BPI_M3_30 -1
#define BPI_M3_32 GPIO_PG13
#define BPI_M3_34 -1
#define BPI_M3_36 GPIO_PE05
#define BPI_M3_38 GPIO_PE18
#define BPI_M3_40 GPIO_PE19
const Banana_Pi_Gpio_Mapping banana_pi_m3_map{
.phys_to_gpio_map =
{
{board_type::pi_physical_pin_e::PI_PHYS_PIN_03, BPI_M3_03},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_05, BPI_M3_05},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_07, BPI_M3_07},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_08, BPI_M3_08},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_10, BPI_M3_10},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_11, BPI_M3_11},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_12, BPI_M3_12},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_13, BPI_M3_13},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_15, BPI_M3_15},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_16, BPI_M3_16},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_18, BPI_M3_18},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_19, BPI_M3_19},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_21, BPI_M3_21},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_22, BPI_M3_22},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_23, BPI_M3_23},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_24, BPI_M3_24},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_26, BPI_M3_26},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_27, BPI_M3_27},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_28, BPI_M3_28},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_29, BPI_M3_29},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_31, BPI_M3_31},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_32, BPI_M3_32},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_33, BPI_M3_33},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_35, BPI_M3_35},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_36, BPI_M3_36},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_37, BPI_M3_37},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_38, BPI_M3_38},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_40, BPI_M3_40},
},
.I2C_DEV = "/dev/i2c-2",
.SPI_DEV = "/dev/spidev0.0",
.I2C_OFFSET = 2,
.SPI_OFFSET = 3,
.PWM_OFFSET = 2,
};

View File

@ -1,122 +0,0 @@
#define BPI_M3_01 -1
#define BPI_M3_03 GPIO_PH05
#define BPI_M3_05 GPIO_PH04
#define BPI_M3_07 GPIO_PL10
#define BPI_M3_09 -1
#define BPI_M3_11 GPIO_PC04
#define BPI_M3_13 GPIO_PC07
#define BPI_M3_15 GPIO_PC17
#define BPI_M3_17 -1
#define BPI_M3_19 GPIO_PC00
#define BPI_M3_21 GPIO_PC01
#define BPI_M3_23 GPIO_PC02
#define BPI_M3_25 -1
#define BPI_M3_27 GPIO_PH03
#define BPI_M3_29 GPIO_PC18
#define BPI_M3_31 GPIO_PG10
#define BPI_M3_33 GPIO_PG11
#define BPI_M3_35 GPIO_PG12
#define BPI_M3_37 GPIO_PE04
#define BPI_M3_39 -1
#define BPI_M3_02 -1
#define BPI_M3_04 -1
#define BPI_M3_06 -1
#define BPI_M3_08 GPIO_PB00
#define BPI_M3_10 GPIO_PB01
#define BPI_M3_12 GPIO_PB03
#define BPI_M3_14 -1
#define BPI_M3_16 GPIO_PB02
#define BPI_M3_18 GPIO_PL08
#define BPI_M3_20 -1
#define BPI_M3_22 GPIO_PL09
#define BPI_M3_24 GPIO_PC03
#define BPI_M3_26 GPIO_PH10
#define BPI_M3_28 GPIO_PH02
#define BPI_M3_30 -1
#define BPI_M3_32 GPIO_PG13
#define BPI_M3_34 -1
#define BPI_M3_36 GPIO_PE05
#define BPI_M3_38 GPIO_PE18
#define BPI_M3_40 GPIO_PE19
//map wpi gpio_num(index) to bp bpio_num(element)
int pinToGpio_BPI_M3 [64] =
{
BPI_M3_11, BPI_M3_12, //0, 1
BPI_M3_13, BPI_M3_15, //2, 3
BPI_M3_16, BPI_M3_18, //4, 5
BPI_M3_22, BPI_M3_07, //6, 7
BPI_M3_03, BPI_M3_05, //8, 9
BPI_M3_24, BPI_M3_26, //10, 11
BPI_M3_19, BPI_M3_21, //12, 13
BPI_M3_23, BPI_M3_08, //14, 15
BPI_M3_10, -1, //16, 17
-1, -1, //18, 19
-1, BPI_M3_29, //20, 21
BPI_M3_31, BPI_M3_33, //22, 23
BPI_M3_35, BPI_M3_37, //24, 25
BPI_M3_32, BPI_M3_36, //26, 27
BPI_M3_38, BPI_M3_40, //28. 29
BPI_M3_27, BPI_M3_28, //30, 31
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 // ... 63
} ;
//map bcm gpio_num(index) to bp gpio_num(element)
int pinTobcm_BPI_M3 [64] =
{
BPI_M3_27, BPI_M3_28, //0, 1
BPI_M3_03, BPI_M3_05, //2, 3
BPI_M3_07, BPI_M3_29, //4, 5
BPI_M3_31, BPI_M3_26, //6, 7
BPI_M3_24, BPI_M3_21, //8, 9
BPI_M3_19, BPI_M3_23, //10, 11
BPI_M3_32, BPI_M3_33, //12, 13
BPI_M3_08, BPI_M3_10, //14, 15
BPI_M3_36, BPI_M3_11, //16, 17
BPI_M3_12, BPI_M3_35, //18, 19
BPI_M3_38, BPI_M3_40, //20, 21
BPI_M3_15, BPI_M3_16, //22, 23
BPI_M3_18, BPI_M3_22, //24, 25
BPI_M3_37, BPI_M3_13, //26, 27
-1, -1,
-1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 // ... 63
} ;
//map phys_num(index) to bp gpio_num(element)
int physToGpio_BPI_M3 [64] =
{
-1, //0
-1, -1, //1, 2
BPI_M3_03, -1, //3, 4
BPI_M3_05, -1, //5, 6
BPI_M3_07, BPI_M3_08, //7, 8
-1, BPI_M3_10, //9, 10
BPI_M3_11, BPI_M3_12, //11, 12
BPI_M3_13, -1, //13, 14
BPI_M3_15, BPI_M3_16, //15, 16
-1, BPI_M3_18, //17, 18
BPI_M3_19, -1, //19, 20
BPI_M3_21, BPI_M3_22, //21, 22
BPI_M3_23, BPI_M3_24, //23, 24
-1, BPI_M3_26, //25, 26
BPI_M3_27, BPI_M3_28, //27, 28
BPI_M3_29, -1, //29, 30
BPI_M3_31, BPI_M3_32, //31, 32
BPI_M3_33, -1, //33, 34
BPI_M3_35, BPI_M3_36, //35, 36
BPI_M3_37, BPI_M3_38, //37, 38
-1, BPI_M3_40, //39, 40
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55
-1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63
} ;
#define M3_I2C_DEV "/dev/i2c-2"
#define M3_SPI_DEV "/dev/spidev0.0"
#define M3_I2C_OFFSET 2
#define M3_SPI_OFFSET 3
#define M3_PWM_OFFSET 2

110
cpp/hal/pi_defs/bpi-m64.cpp Executable file
View File

@ -0,0 +1,110 @@
/*
Copyright (c) 2014-2017 Banana Pi
Updates Copyright (C) 2022 akuker
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "hal/pi_defs/bpi-gpio.h"
/* The following define the mapping of the Banana Pi CPU pins to the logical
* GPIO numbers. The GPIO numbers are used by the software to set/configure
* the CPU registers. */
#define BPI_M64_01 -1
#define BPI_M64_03 GPIO_PH03
#define BPI_M64_05 GPIO_PH02
#define BPI_M64_07 GPIO_PH06
#define BPI_M64_09 -1
#define BPI_M64_11 GPIO_PH07
#define BPI_M64_13 GPIO_PH10
#define BPI_M64_15 GPIO_PH11
#define BPI_M64_17 -1
#define BPI_M64_19 GPIO_PD02
#define BPI_M64_21 GPIO_PD03
#define BPI_M64_23 GPIO_PD01
#define BPI_M64_25 -1
#define BPI_M64_27 GPIO_PC04
#define BPI_M64_29 GPIO_PC07
#define BPI_M64_31 GPIO_PB05
#define BPI_M64_33 GPIO_PB04
#define BPI_M64_35 GPIO_PB06
#define BPI_M64_37 GPIO_PL12
#define BPI_M64_39 -1
#define BPI_M64_02 -1
#define BPI_M64_04 -1
#define BPI_M64_06 -1
#define BPI_M64_08 GPIO_PB00
#define BPI_M64_10 GPIO_PB01
#define BPI_M64_12 GPIO_PB03
#define BPI_M64_14 -1
#define BPI_M64_16 GPIO_PB02
#define BPI_M64_18 GPIO_PD04
#define BPI_M64_20 -1
#define BPI_M64_22 GPIO_PC00
#define BPI_M64_24 GPIO_PD00
#define BPI_M64_26 GPIO_PC02
#define BPI_M64_28 GPIO_PC03
#define BPI_M64_30 -1
#define BPI_M64_32 GPIO_PB07
#define BPI_M64_34 -1
#define BPI_M64_36 GPIO_PL09
#define BPI_M64_38 GPIO_PL07
#define BPI_M64_40 GPIO_PL08
const Banana_Pi_Gpio_Mapping banana_pi_m64_map{
.phys_to_gpio_map =
{
{board_type::pi_physical_pin_e::PI_PHYS_PIN_03, BPI_M64_03},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_05, BPI_M64_05},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_07, BPI_M64_07},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_08, BPI_M64_08},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_10, BPI_M64_10},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_11, BPI_M64_11},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_12, BPI_M64_12},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_13, BPI_M64_13},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_15, BPI_M64_15},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_16, BPI_M64_16},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_18, BPI_M64_18},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_19, BPI_M64_19},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_21, BPI_M64_21},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_22, BPI_M64_22},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_23, BPI_M64_23},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_24, BPI_M64_24},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_26, BPI_M64_26},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_27, BPI_M64_27},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_28, BPI_M64_28},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_29, BPI_M64_29},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_31, BPI_M64_31},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_32, BPI_M64_32},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_33, BPI_M64_33},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_35, BPI_M64_35},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_36, BPI_M64_36},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_37, BPI_M64_37},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_38, BPI_M64_38},
{board_type::pi_physical_pin_e::PI_PHYS_PIN_40, BPI_M64_40},
},
.I2C_DEV = "/dev/i2c-1",
.SPI_DEV = "/dev/spidev1.0",
.I2C_OFFSET = 2,
.SPI_OFFSET = 4,
.PWM_OFFSET = -1,
};

View File

@ -1,123 +0,0 @@
#define BPI_M64_01 -1
#define BPI_M64_03 GPIO_PH03
#define BPI_M64_05 GPIO_PH02
#define BPI_M64_07 GPIO_PH06
#define BPI_M64_09 -1
#define BPI_M64_11 GPIO_PH07
#define BPI_M64_13 GPIO_PH10
#define BPI_M64_15 GPIO_PH11
#define BPI_M64_17 -1
#define BPI_M64_19 GPIO_PD02
#define BPI_M64_21 GPIO_PD03
#define BPI_M64_23 GPIO_PD01
#define BPI_M64_25 -1
#define BPI_M64_27 GPIO_PC04
#define BPI_M64_29 GPIO_PC07
#define BPI_M64_31 GPIO_PB05
#define BPI_M64_33 GPIO_PB04
#define BPI_M64_35 GPIO_PB06
#define BPI_M64_37 GPIO_PL12
#define BPI_M64_39 -1
#define BPI_M64_02 -1
#define BPI_M64_04 -1
#define BPI_M64_06 -1
#define BPI_M64_08 GPIO_PB00
#define BPI_M64_10 GPIO_PB01
#define BPI_M64_12 GPIO_PB03
#define BPI_M64_14 -1
#define BPI_M64_16 GPIO_PB02
#define BPI_M64_18 GPIO_PD04
#define BPI_M64_20 -1
#define BPI_M64_22 GPIO_PC00
#define BPI_M64_24 GPIO_PD00
#define BPI_M64_26 GPIO_PC02
#define BPI_M64_28 GPIO_PC03
#define BPI_M64_30 -1
#define BPI_M64_32 GPIO_PB07
#define BPI_M64_34 -1
#define BPI_M64_36 GPIO_PL09
#define BPI_M64_38 GPIO_PL07
#define BPI_M64_40 GPIO_PL08
//map wpi gpio_num(index) to bp bpio_num(element)
int pinToGpio_BPI_M64 [64] =
{
BPI_M64_11, BPI_M64_12, //0, 1
BPI_M64_13, BPI_M64_15, //2, 3
BPI_M64_16, BPI_M64_18, //4, 5
BPI_M64_22, BPI_M64_07, //6, 7
BPI_M64_03, BPI_M64_05, //8, 9
BPI_M64_24, BPI_M64_26, //10, 11
BPI_M64_19, BPI_M64_21, //12, 13
BPI_M64_23, BPI_M64_08, //14, 15
BPI_M64_10, -1, //16, 17
-1, -1, //18, 19
-1, BPI_M64_29, //20, 21
BPI_M64_31, BPI_M64_33, //22, 23
BPI_M64_35, BPI_M64_37, //24, 25
BPI_M64_32, BPI_M64_36, //26, 27
BPI_M64_38, BPI_M64_40, //28. 29
BPI_M64_27, BPI_M64_28, //30, 31
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
} ;
//map bcm gpio_num(index) to bp gpio_num(element)
int pinTobcm_BPI_M64 [64] =
{
BPI_M64_27, BPI_M64_28, //0, 1
BPI_M64_03, BPI_M64_05, //2, 3
BPI_M64_07, BPI_M64_29, //4, 5
BPI_M64_31, BPI_M64_26, //6, 7
BPI_M64_24, BPI_M64_21, //8, 9
BPI_M64_19, BPI_M64_23, //10, 11
BPI_M64_32, BPI_M64_33, //12, 13
BPI_M64_08, BPI_M64_10, //14, 15
BPI_M64_36, BPI_M64_11, //16, 17
BPI_M64_12, BPI_M64_35, //18, 19
BPI_M64_38, BPI_M64_40, //20, 21
BPI_M64_15, BPI_M64_16, //22, 23
BPI_M64_18, BPI_M64_22, //24, 25
BPI_M64_37, BPI_M64_13, //26, 27
-1, -1,
-1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 63
} ;
//map phys_num(index) to bp gpio_num(element)
int physToGpio_BPI_M64 [64] =
{
-1, //0
-1, -1, //1, 2
BPI_M64_03, -1, //3, 4
BPI_M64_05, -1, //5, 6
BPI_M64_07, BPI_M64_08, //7, 8
-1, BPI_M64_10, //9, 10
BPI_M64_11, BPI_M64_12, //11, 12
BPI_M64_13, -1, //13, 14
BPI_M64_15, BPI_M64_16, //15, 16
-1, BPI_M64_18, //17, 18
BPI_M64_19, -1, //19, 20
BPI_M64_21, BPI_M64_22, //21, 22
BPI_M64_23, BPI_M64_24, //23, 24
-1, BPI_M64_26, //25, 26
BPI_M64_27, BPI_M64_28, //27, 28
BPI_M64_29, -1, //29, 30
BPI_M64_31, BPI_M64_32, //31, 32
BPI_M64_33, -1, //33, 34
BPI_M64_35, BPI_M64_36, //35, 36
BPI_M64_37, BPI_M64_38, //37, 38
-1, BPI_M64_40, //39, 40
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //41-> 55
-1, -1, -1, -1, -1, -1, -1, -1 // 56-> 63
} ;
#define M64_I2C_DEV "/dev/i2c-1"
#define M64_SPI_DEV "/dev/spidev1.0"
#define M64_I2C_OFFSET 2
#define M64_SPI_OFFSET 4
#define M64_PWM_OFFSET -1