I have a chunk of code that toggles different functions on hardware pins,
that looks like this:
enum Function {
GPIO = 0,
F1 = 1,
F2 = 2,
F3 = 3,
}
fn set_mode(port: u8, pin: u8, fun: Function)
What I would like to have is an enum of human-readable values instead of
F1/F2/F3
On 30/03/2014 09:50, Vladimir Pouzanov wrote:
I have a chunk of code that toggles different functions on hardware
pins, that looks like this:
enum Function {
GPIO = 0,
F1 = 1,
F2 = 2,
F3 = 3,
}
fn set_mode(port: u8, pin: u8, fun: Function)
What I would like to have
On 30/03/14 20:12, Simon Sapin wrote:
On 30/03/2014 09:50, Vladimir Pouzanov wrote:
I have a chunk of code that toggles different functions on hardware
pins, that looks like this:
enum Function {
GPIO = 0,
F1 = 1,
F2 = 2,
F3 = 3,
}
fn set_mode(port: u8, pin: u8, fun
That shifts the issue even more into runtime, doesn't it?
My goal is to find a way to resolve a tuple of (u8, u8, FuncNameEnum) to
u8, where FuncNameEnum is a long enum of all possible functions. And I need
to do that in compile time.
One way I see that is to make a really long list of enums like
On 30/03/2014 10:30, Vladimir Pouzanov wrote:
That shifts the issue even more into runtime, doesn't it?
My goal is to find a way to resolve a tuple of (u8, u8, FuncNameEnum) to
u8, where FuncNameEnum is a long enum of all possible functions. And I
need to do that in compile time.
One way I see
Ok, so I have a number of hardware pins which are defined by port+pin
numbers. Each pin can be connected to different peripheral (e.g. generic
purpose i/o, serial, analog in) which defines it's function.
So, to configure that I have a few u32 registers where each pair of bits
defines a function fo
On Sun, Mar 30, 2014 at 8:08 AM, Vladimir Pouzanov wrote:
> gpio::Pin::new(0, 15, gpio::Out, gpio::UART1_TXD); // p13 -> TXD
>
> compiles, but something like
>
> gpio::Pin::new(0, 15, gpio::Out, gpio::SPI_MISO); // p13 -> TXD
>
> would fail, because there's no SPI_MISO defined for port 0 pin 1
That actually sounds like a good option, thanks!
On Sun, Mar 30, 2014 at 11:22 PM, comex wrote:
> On Sun, Mar 30, 2014 at 8:08 AM, Vladimir Pouzanov
> wrote:
> > gpio::Pin::new(0, 15, gpio::Out, gpio::UART1_TXD); // p13 -> TXD
> >
> > compiles, but something like
> >
> > gpio::Pin::new(0,