correct spelling of multiplexer

This commit is contained in:
Carl Philipp Klemm 2023-06-30 16:12:39 +02:00
parent 0ec7d189b2
commit 1004ecee2b
4 changed files with 47 additions and 47 deletions

View file

@ -1,8 +1,8 @@
/*! \mainpage librelaxisloader manual /*! \mainpage libeismultiplexer manual
libeismulitplexer is a shared library that allows you to controll EISmulitplexer devices libeismultiplexer is a shared library that allows you to control EISmultiplexer devices
An API referance can be found here: \subpage API An API reference can be found here: \subpage API
## Example usage: ## Example usage:
@ -14,11 +14,11 @@ _______
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
// Eatch connection to a device is required to have a corrisponding eismulitplexer struct // Each connection to a device is required to have a corresponding eismultiplexer struct
struct eismulitplexer multiplexer; struct eismultiplexer multiplexer;
// Connect to the first device found // Connect to the first device found
int ret = eismulitplexer_connect(&multiplexer, 0); int ret = eismultiplexer_connect(&multiplexer, 0);
if(ret != 0) if(ret != 0)
{ {
printf("Can not connect to EISmultiplexer device\n"); printf("Can not connect to EISmultiplexer device\n");
@ -26,7 +26,7 @@ int main(int argc, char* argv[])
} }
// Connect channels A and C to the common output // Connect channels A and C to the common output
ret = eismulitplexer_connect_channel(&multiplexer, CHANNEL_A | CHANNEL_C); ret = eismultiplexer_connect_channel(&multiplexer, CHANNEL_A | CHANNEL_C);
if(ret != 0) if(ret != 0)
{ {
printf("Failure to communicate with the device\n"); printf("Failure to communicate with the device\n");
@ -34,7 +34,7 @@ int main(int argc, char* argv[])
} }
// Disconnect from device // Disconnect from device
eismulitplexer_disconnect(&multiplexer); eismultiplexer_disconnect(&multiplexer);
return 0; return 0;
} }
@endcode @endcode

View file

@ -32,7 +32,7 @@ static void usleep(uint64_t microseconds)
static void dataCallback(uint8_t request, unsigned char* data, size_t length, void* user_data) static void dataCallback(uint8_t request, unsigned char* data, size_t length, void* user_data)
{ {
struct eismulitplexer* muliplexer = user_data; struct eismultiplexer* muliplexer = user_data;
if(length >= 1) if(length >= 1)
muliplexer->activeChannels = data[0]; muliplexer->activeChannels = data[0];
@ -40,7 +40,7 @@ static void dataCallback(uint8_t request, unsigned char* data, size_t length, vo
sem_post(&muliplexer->readSem); sem_post(&muliplexer->readSem);
} }
int eismulitplexer_connect(struct eismulitplexer* muliplexer, int serial) int eismultiplexer_connect(struct eismultiplexer* muliplexer, int serial)
{ {
int ret; int ret;
muliplexer->priv = malloc(sizeof(*muliplexer->priv)); muliplexer->priv = malloc(sizeof(*muliplexer->priv));
@ -61,7 +61,7 @@ int eismulitplexer_connect(struct eismulitplexer* muliplexer, int serial)
return 0; return 0;
} }
int eismulitplexer_connect_channel_exclusive(struct eismulitplexer* muliplexer, channel_t channel) int eismultiplexer_connect_channel_exclusive(struct eismultiplexer* muliplexer, channel_t channel)
{ {
uint16_t wValue; uint16_t wValue;
// we compile with fno-strict-aliasing // we compile with fno-strict-aliasing
@ -74,21 +74,21 @@ int eismulitplexer_connect_channel_exclusive(struct eismulitplexer* muliplexer,
return ret; return ret;
} }
int eismulitplexer_connect_channel(struct eismulitplexer* muliplexer, channel_t channel) int eismultiplexer_connect_channel(struct eismultiplexer* muliplexer, channel_t channel)
{ {
channel_t channels = eismulitplexer_get_connected(muliplexer); channel_t channels = eismultiplexer_get_connected(muliplexer);
channels |= channel; channels |= channel;
return eismulitplexer_connect_channel_exclusive(muliplexer, channels); return eismultiplexer_connect_channel_exclusive(muliplexer, channels);
} }
int eismulitplexer_disconnect_channel(struct eismulitplexer* muliplexer, channel_t channel) int eismultiplexer_disconnect_channel(struct eismultiplexer* muliplexer, channel_t channel)
{ {
channel_t channels = eismulitplexer_get_connected(muliplexer); channel_t channels = eismultiplexer_get_connected(muliplexer);
channels &= ~channel; channels &= ~channel;
return eismulitplexer_connect_channel_exclusive(muliplexer, channels); return eismultiplexer_connect_channel_exclusive(muliplexer, channels);
} }
channel_t eismulitplexer_get_connected(struct eismulitplexer* muliplexer) channel_t eismultiplexer_get_connected(struct eismultiplexer* muliplexer)
{ {
usbshm_readControlTransfer(muliplexer->priv, 3, 1); usbshm_readControlTransfer(muliplexer->priv, 3, 1);
sem_wait(&muliplexer->readSem); sem_wait(&muliplexer->readSem);
@ -96,7 +96,7 @@ channel_t eismulitplexer_get_connected(struct eismulitplexer* muliplexer)
} }
int eismulitplexer_set_led(struct eismulitplexer* muliplexer, bool on) int eismultiplexer_set_led(struct eismultiplexer* muliplexer, bool on)
{ {
int ret; int ret;
while((ret = usbshm_writeControlTransfer(muliplexer->priv, on, NULL, 0, 0, 0)) == USBSHM_ERROR_AGAIN) while((ret = usbshm_writeControlTransfer(muliplexer->priv, on, NULL, 0, 0, 0)) == USBSHM_ERROR_AGAIN)
@ -104,7 +104,7 @@ int eismulitplexer_set_led(struct eismulitplexer* muliplexer, bool on)
return ret; return ret;
} }
void eismulitplexer_disconnect(struct eismulitplexer* muliplexer) void eismultiplexer_disconnect(struct eismultiplexer* muliplexer)
{ {
usbshm_distroy(muliplexer->priv); usbshm_distroy(muliplexer->priv);
free(muliplexer->priv); free(muliplexer->priv);

View file

@ -23,9 +23,9 @@
#include <stdbool.h> #include <stdbool.h>
/** /**
Api to controll EISmulitplexer devices. Api to controll EISmultiplexer devices.
* @defgroup API User API * @defgroup API User API
* This api allows you to controll the EISmulitplexer device. * This api allows you to controll the EISmultiplexer device.
* @{ * @{
*/ */
@ -44,64 +44,64 @@ typedef enum {
CHANNEL_NONE = 0, CHANNEL_NONE = 0,
} channel_t; } channel_t;
struct eismulitplexer { struct eismultiplexer {
struct usbshm* priv; struct usbshm* priv;
sem_t readSem; sem_t readSem;
channel_t activeChannels; channel_t activeChannels;
}; };
/** /**
* @brief Attempts to connect to a EISmulitplexer device and initalizes a eismulitplexer struct * @brief Attempts to connect to a EISmultiplexer device and initalizes a eismultiplexer struct
* @param muliplexer pointer to a eismulitplexer struct to initalize * @param muliplexer pointer to a eismultiplexer struct to initalize
* @param serial The serial number of the device to connect to, or 0 for any * @param serial The serial number of the device to connect to, or 0 for any
* @return 0 on sucess and < 0 on failure * @return 0 on sucess and < 0 on failure
*/ */
int eismulitplexer_connect(struct eismulitplexer* muliplexer, int serial); int eismultiplexer_connect(struct eismultiplexer* muliplexer, int serial);
/** /**
* @brief Conects the given channel(s) to the common inputs * @brief Conects the given channel(s) to the common inputs
* @param muliplexer pointer to a eismulitplexer struct * @param muliplexer pointer to a eismultiplexer struct
* @param channel A channel to connect, multiple channels can be specified by or'ing together the chanel flags e.g. (CHANNEL_A | CHANNEL_B) * @param channel A channel to connect, multiple channels can be specified by or'ing together the chanel flags e.g. (CHANNEL_A | CHANNEL_B)
* @return 0 on sucess and < 0 on failure * @return 0 on sucess and < 0 on failure
*/ */
int eismulitplexer_connect_channel(struct eismulitplexer* muliplexer, channel_t channel); int eismultiplexer_connect_channel(struct eismultiplexer* muliplexer, channel_t channel);
/** /**
* @brief Conects the given channel(s) to the common inputs disconnecting all others * @brief Conects the given channel(s) to the common inputs disconnecting all others
* @param muliplexer pointer to a eismulitplexer struct * @param muliplexer pointer to a eismultiplexer struct
* @param channel A channel to connect, multiple channels can be specified by or'ing together the chanel flags e.g. (CHANNEL_A | CHANNEL_B) * @param channel A channel to connect, multiple channels can be specified by or'ing together the chanel flags e.g. (CHANNEL_A | CHANNEL_B)
* @return 0 on sucess and < 0 on failure * @return 0 on sucess and < 0 on failure
*/ */
int eismulitplexer_connect_channel_exclusive(struct eismulitplexer* muliplexer, channel_t channel); int eismultiplexer_connect_channel_exclusive(struct eismultiplexer* muliplexer, channel_t channel);
/** /**
* @brief Disconnect the given channel(s) to the common inputs disconnecting all others * @brief Disconnect the given channel(s) to the common inputs disconnecting all others
* @param muliplexer pointer to a eismulitplexer struct * @param muliplexer pointer to a eismultiplexer struct
* @param channel A channel to connect, multiple channels can be specified by or'ing together the chanel flags e.g. (CHANNEL_A | CHANNEL_B) * @param channel A channel to connect, multiple channels can be specified by or'ing together the chanel flags e.g. (CHANNEL_A | CHANNEL_B)
* All channels can be dissconnected by passing CHANNEL_NONE * All channels can be dissconnected by passing CHANNEL_NONE
* @return 0 on sucess and < 0 on failure * @return 0 on sucess and < 0 on failure
*/ */
int eismulitplexer_disconnect_channel(struct eismulitplexer* muliplexer, channel_t channel); int eismultiplexer_disconnect_channel(struct eismultiplexer* muliplexer, channel_t channel);
/** /**
* @brief Returns the channels currently connected * @brief Returns the channels currently connected
* @param muliplexer pointer to a eismulitplexer struct * @param muliplexer pointer to a eismultiplexer struct
* @return channels connected as a bitfield * @return channels connected as a bitfield
*/ */
channel_t eismulitplexer_get_connected(struct eismulitplexer* muliplexer); channel_t eismultiplexer_get_connected(struct eismultiplexer* muliplexer);
/** /**
* @brief Turns the led on the pcb on or off * @brief Turns the led on the pcb on or off
* @param muliplexer pointer to a eismulitplexer struct * @param muliplexer pointer to a eismultiplexer struct
* @param on true to turn the led on, false to turn it off * @param on true to turn the led on, false to turn it off
* @return 0 on sucess and < 0 on failure * @return 0 on sucess and < 0 on failure
*/ */
int eismulitplexer_set_led(struct eismulitplexer* muliplexer, bool on); int eismultiplexer_set_led(struct eismultiplexer* muliplexer, bool on);
/** /**
* @brief Disconnects from the eismulitplexer * @brief Disconnects from the eismultiplexer
*/ */
void eismulitplexer_disconnect(struct eismulitplexer* muliplexer); void eismultiplexer_disconnect(struct eismultiplexer* muliplexer);
#ifdef __cplusplus #ifdef __cplusplus
} }

18
main.c
View file

@ -74,9 +74,9 @@ int main(int argc, char* argv[])
return 0; return 0;
} }
struct eismulitplexer multiplexer; struct eismultiplexer multiplexer;
if(eismulitplexer_connect(&multiplexer, 0)) if(eismultiplexer_connect(&multiplexer, 0))
{ {
printf("Can not connect to EISmultiplexer device\n"); printf("Can not connect to EISmultiplexer device\n");
return 1; return 1;
@ -85,7 +85,7 @@ int main(int argc, char* argv[])
if(argc != 4) if(argc != 4)
{ {
print_help(argv[0]); print_help(argv[0]);
eismulitplexer_disconnect(&multiplexer); eismultiplexer_disconnect(&multiplexer);
return 2; return 2;
} }
@ -93,29 +93,29 @@ int main(int argc, char* argv[])
if(channel == CHANNEL_NONE) if(channel == CHANNEL_NONE)
{ {
printf("%c is not a valid channel", argv[2][0]); printf("%c is not a valid channel", argv[2][0]);
eismulitplexer_disconnect(&multiplexer); eismultiplexer_disconnect(&multiplexer);
return 2; return 2;
} }
if(strcmp(argv[1], "connect") == 0) if(strcmp(argv[1], "connect") == 0)
{ {
if(eismulitplexer_connect_channel(&multiplexer, channel)) if(eismultiplexer_connect_channel(&multiplexer, channel))
{ {
printf("could not connect channel %c", argv[2][0]); printf("could not connect channel %c", argv[2][0]);
eismulitplexer_disconnect(&multiplexer); eismultiplexer_disconnect(&multiplexer);
return 3; return 3;
} }
} }
else if(strcmp(argv[1], "disconnect") == 0) else if(strcmp(argv[1], "disconnect") == 0)
{ {
if(eismulitplexer_disconnect_channel(&multiplexer, channel)) if(eismultiplexer_disconnect_channel(&multiplexer, channel))
{ {
printf("could not connect channel %c", argv[2][0]); printf("could not connect channel %c", argv[2][0]);
eismulitplexer_disconnect(&multiplexer); eismultiplexer_disconnect(&multiplexer);
return 3; return 3;
} }
} }
eismulitplexer_disconnect(&multiplexer); eismultiplexer_disconnect(&multiplexer);
return 0; return 0;
} }