mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
mmap-gpio: remove deprecated mmapped gpio function calls
The memory mapped GPIO function calls have been deprecated and in turn removed from the UPM libraries. MRAA now provides the best/fastest GPIO access possible based on the selected platform/pin automatically. Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
parent
6ae7e9125b
commit
62f84dcc47
@ -44,7 +44,6 @@ GroveUltraSonic::GroveUltraSonic (int pin) {
|
||||
fprintf (stderr, "Are you sure that pin%d you requested is valid on your platform?", pin);
|
||||
exit (1);
|
||||
}
|
||||
mraa_gpio_use_mmaped(m_pinCtx, 1);
|
||||
mraa_gpio_isr (m_pinCtx, MRAA_GPIO_EDGE_BOTH,
|
||||
&signalISR, this);
|
||||
}
|
||||
|
@ -95,19 +95,6 @@ my9221_context my9221_init(int dataPin, int clockPin,
|
||||
|
||||
mraa_gpio_dir(dev->gpioData, MRAA_GPIO_OUT);
|
||||
|
||||
#if defined(UPM_PLATFORM_LINUX)
|
||||
// we warn if these fail, since it may not be possible to handle
|
||||
// more than one instance
|
||||
|
||||
if (mraa_gpio_use_mmaped(dev->gpioClk, 1))
|
||||
printf("%s: Warning: mmap of Clk pin failed, correct operation "
|
||||
"may be affected.\n", __FUNCTION__);
|
||||
|
||||
if (mraa_gpio_use_mmaped(dev->gpioData, 1))
|
||||
printf("%s: Warning: mmap of Data pin failed, correct operation "
|
||||
"may be affected.\n", __FUNCTION__);
|
||||
#endif // UPM_PLATFORM_LINUX
|
||||
|
||||
my9221_set_low_intensity_value(dev, 0x00); // full off
|
||||
my9221_set_high_intensity_value(dev, 0xff); // full bright
|
||||
|
||||
|
@ -100,11 +100,6 @@ speaker_context speaker_init(int pin)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(UPM_PLATFORM_LINUX)
|
||||
// Would prefer, but not fatal if not available
|
||||
mraa_gpio_use_mmaped(dev->gpio, 1);
|
||||
#endif // UPM_PLATFORM_LINUX
|
||||
|
||||
mraa_gpio_dir(dev->gpio, MRAA_GPIO_OUT);
|
||||
|
||||
return dev;
|
||||
|
@ -53,13 +53,11 @@ SSD1351::SSD1351 (int oc, int dc, int rst) :
|
||||
": Could not initialize CS pin");
|
||||
return;
|
||||
}
|
||||
m_oc.useMmap(true);
|
||||
if (m_dc.dir(mraa::DIR_OUT) != mraa::SUCCESS) {
|
||||
throw std::runtime_error(string(__FUNCTION__) +
|
||||
": Could not initialize data/cmd pin");
|
||||
return;
|
||||
}
|
||||
m_dc.useMmap(true);
|
||||
if (m_rst.dir(mraa::DIR_OUT) != mraa::SUCCESS) {
|
||||
throw std::runtime_error(string(__FUNCTION__) +
|
||||
": Could not initialize reset pin");
|
||||
|
@ -47,7 +47,6 @@ StepMotor::StepMotor (int dirPin, int stePin, int steps, int enPin)
|
||||
": Could not initialize dirPin as output");
|
||||
return;
|
||||
}
|
||||
m_dirPinCtx.useMmap(true);
|
||||
m_dirPinCtx.write(0);
|
||||
|
||||
if (m_stePinCtx.dir(mraa::DIR_OUT) != mraa::SUCCESS) {
|
||||
@ -55,7 +54,6 @@ StepMotor::StepMotor (int dirPin, int stePin, int steps, int enPin)
|
||||
": Could not initialize stePin as output");
|
||||
return;
|
||||
}
|
||||
m_stePinCtx.useMmap(true);
|
||||
m_stePinCtx.write(0);
|
||||
|
||||
if (enPin >= 0) {
|
||||
@ -65,7 +63,6 @@ StepMotor::StepMotor (int dirPin, int stePin, int steps, int enPin)
|
||||
": Could not initialize enPin as output");
|
||||
return;
|
||||
}
|
||||
m_enPinCtx->useMmap(true);
|
||||
enable(true);
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,6 @@ SX1276::SX1276(uint8_t chipRev, int bus, int cs, int resetPin, int dio0,
|
||||
m_spi.frequency(10000000); // 10Mhz, if supported
|
||||
|
||||
m_gpioCS.dir(mraa::DIR_OUT);
|
||||
m_gpioCS.useMmap(true);
|
||||
csOff();
|
||||
|
||||
m_gpioReset.dir(mraa::DIR_IN);
|
||||
|
@ -40,7 +40,7 @@ const uint8_t m_char[26] = {0x77, 0x7c, 0x39, 0x5e, 0x79,
|
||||
using namespace std;
|
||||
using namespace upm;
|
||||
|
||||
upm::TM1637::TM1637(int clk_pin, int dio_pin, int bright, M_FAST_GPIO mmio) {
|
||||
upm::TM1637::TM1637(int clk_pin, int dio_pin, int bright) {
|
||||
|
||||
if((m_clk = mraa_gpio_init(clk_pin)) == NULL){
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
@ -61,15 +61,6 @@ upm::TM1637::TM1637(int clk_pin, int dio_pin, int bright, M_FAST_GPIO mmio) {
|
||||
mraa_gpio_mode(m_clk, MRAA_GPIO_PULLUP);
|
||||
mraa_gpio_mode(m_dio, MRAA_GPIO_PULLUP);
|
||||
|
||||
if(mmio){
|
||||
if(mraa_gpio_use_mmaped(m_clk, 1) != MRAA_SUCCESS ||
|
||||
mraa_gpio_use_mmaped(m_dio, 1) != MRAA_SUCCESS){
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": mraa_gpio_use_mmaped() failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mraa_gpio_write(m_clk, 0);
|
||||
mraa_gpio_write(m_dio, 0);
|
||||
|
||||
|
@ -74,22 +74,14 @@ namespace upm
|
||||
class TM1637
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Enum for the memory-mapped GPIO
|
||||
*/
|
||||
typedef enum {
|
||||
NO = 0,
|
||||
YES = 1
|
||||
} M_FAST_GPIO;
|
||||
/**
|
||||
* TM1637 constructor
|
||||
*
|
||||
* @param clk_pin Clock pin the sensor is connected to
|
||||
* @param dio_pin Data pin the sensor is connected to
|
||||
* @param bright Initial brightness, from 0 (dark) to 7 (bright) (default is 3)
|
||||
* @param mmio Fast memory-mapped GPIO writes; default is yes
|
||||
*/
|
||||
TM1637(int clk_pin, int dio_pin, int bright = 3, M_FAST_GPIO mmio = YES);
|
||||
TM1637(int clk_pin, int dio_pin, int bright = 3);
|
||||
/**
|
||||
* TM1637 destructor
|
||||
*/
|
||||
|
@ -44,7 +44,6 @@ UltraSonic::UltraSonic (int pin) {
|
||||
fprintf (stderr, "Are you sure that pin%d you requested is valid on your platform?", pin);
|
||||
exit (1);
|
||||
}
|
||||
mraa_gpio_use_mmaped(m_pinCtx, 1);
|
||||
mraa_gpio_isr (m_pinCtx, MRAA_GPIO_EDGE_BOTH,
|
||||
&signalISR, this);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user