mirror of
https://github.com/eclipse/upm.git
synced 2025-03-28 03:10:06 +03:00
grovecircularled: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
parent
1079baf2fd
commit
d7b8fac41b
@ -26,6 +26,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <stdexcept>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@ -38,6 +40,23 @@ GroveCircularLED::GroveCircularLED (uint8_t di, uint8_t dcki)
|
|||||||
m_dataPinCtx(di) {
|
m_dataPinCtx(di) {
|
||||||
mraa::Result error = mraa::SUCCESS;
|
mraa::Result error = mraa::SUCCESS;
|
||||||
|
|
||||||
|
// init clock context
|
||||||
|
m_clkPinCtx = mraa_gpio_init(dcki);
|
||||||
|
if (m_clkPinCtx == NULL) {
|
||||||
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
|
": mraa_gpio_init(dcki) failed, invalid pin?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mraa_gpio_use_mmaped(m_clkPinCtx, 1);
|
||||||
|
|
||||||
|
// init data context
|
||||||
|
m_dataPinCtx = mraa_gpio_init(di);
|
||||||
|
if (m_dataPinCtx == NULL) {
|
||||||
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
|
": mraa_gpio_init(di) failed, invalid pin?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_clkPinCtx.useMmap(true);
|
m_clkPinCtx.useMmap(true);
|
||||||
m_dataPinCtx.useMmap(true);
|
m_dataPinCtx.useMmap(true);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user