6 Software
User Manual
85/374
6.10
Digital Input / Output
High Level Hardware Access
Example: C - Code Read / Write on PIN1
// This example describes how to read / write on /proc/stw_io/PIN1
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <fcntl.h>
#include "stwtypes.h"
void mv_ToggleOutput (void)
{
charn cn_Status = 0;
fd_set t_Readfds;
struct timeval t_Timeout;
sint16 s16_Fd;
// File descriptor
// Set timeout to zero --> no wait time
t_Timeout.tv_sec = 0;
t_Timeout.tv_usec = 0;
s16_Fd = open ("/proc/stw_io/PIN1", O_RDWR);
// Open PIN1
if (s16_Fd >= 0)
{
// Clear fds
FD_ZERO (&t_Readfds);
// Set
FD_SET (s16_Fd, &t_Readfds);
if (select ( 1, &t_Readfds, NULL, NULL, &t_Timeout) > 0)
{
// Check if the corresponding bit is set in the fds
if (FD_ISSET (s16_Fd, &t_Readfds))
{
// Read from /proc/stw_io/PIN1
(void)read (s16_Fd, &cn_Status, sizeof (charn));
// If cn_Status is not Zero 0 == 0x30 than set cn_Status to zero,
// else set it to 1
cn_Status = (cn_Status != 0x30)? 0x30: 0x31;
// Write to /proc/stw_io/PIN1
(void) write (s16_Fd, &cn_Status, sizeof (charn));
}
}
(void) close(s16_Fd);
}
}
Low Level Hardware Access
Path
Input
information
Output
information
Description
/proc/stw_io/PIN1
p1
p2
This user space interface reads and writes on digital input /
output PIN.
p1:
< 0 > .. sets digital value to low level
< 1..n > .. sets digital value to high level
p2:
Содержание TC1
Страница 1: ...TC1 User Manual Version of this document V1 00r0 ...
Страница 25: ...5 Hardware User Manual 25 374 5 2 2 Block Diagram Variant TC1 WIFI ...
Страница 34: ...5 Hardware User Manual 34 374 5 6 Housing Connector Top view and side view Bottom View ...
Страница 125: ...7 Teleservice Application Framework User Manual 125 374 TAF overview ...
Страница 174: ...7 Teleservice Application Framework User Manual 174 374 ADDRESS 6 SIZE 4 TYPE UINT32 UNIT COMMENT EnginePower ...
Страница 190: ...7 Teleservice Application Framework User Manual 190 374 How the logger mechanism works ...
Страница 223: ...7 Teleservice Application Framework User Manual 223 374 Association between logic hysteresis and threshold ...
Страница 293: ...8 Development Tools User Manual 293 374 3 Adapt the Build Options in order to build the binary with debug symbols ...
Страница 302: ...8 Development Tools User Manual 302 374 2 Adapt the Build Options in order to build the binary with debug symbols ...