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:
Summary of Contents for TC1
Page 1: ...TC1 User Manual Version of this document V1 00r0 ...
Page 25: ...5 Hardware User Manual 25 374 5 2 2 Block Diagram Variant TC1 WIFI ...
Page 34: ...5 Hardware User Manual 34 374 5 6 Housing Connector Top view and side view Bottom View ...
Page 125: ...7 Teleservice Application Framework User Manual 125 374 TAF overview ...
Page 190: ...7 Teleservice Application Framework User Manual 190 374 How the logger mechanism works ...