:cup:
туда
Сообщений 131 страница 140 из 537
Поделиться1322008-08-29 15:42:38
:boys:
Поделиться1332008-08-29 20:14:52
ничего себе
Поделиться1342008-08-30 14:36:28
поезд уже ушел.... а маршрутка едет в выборг!
Поделиться1352008-08-31 17:13:33
а тебе - чего?
Поделиться1362008-09-01 01:33:54
а... нинаю... фтомта идела...
Поделиться1372008-09-01 14:31:28
class CGpio
{
public:
CGpio();
~CGpio();
enum PinDirection
{
unknown = -1, in, out
};
PinDirection GetPinDirection( int pin ) const;
int SetPinDirection( int pin, PinDirection dir );
int GetPinValue( int pin ) const;
int SetPinValue( int pin, int value );
private:
PUCHAR m_reg_base;
PULONG m_gplr[4];
PULONG m_gpdr[4];
PULONG m_gpsr[4];
PULONG m_gpcr[4];
};
Поделиться1382008-09-01 14:53:55
#include <windows.h>
#include "gpio.h"
#define GPIO_BASE 0x40E00000
#define GPIO_SIZE 0x14C
#define GPLR0_OFFSET 0x000
#define GPLR1_OFFSET 0x004
#define GPLR2_OFFSET 0x008
#define GPLR3_OFFSET 0x100
#define GPDR0_OFFSET 0x00C
#define GPDR1_OFFSET 0x010
#define GPDR2_OFFSET 0x014
#define GPDR3_OFFSET 0x10C
#define GPSR0_OFFSET 0x018
#define GPSR1_OFFSET 0x01C
#define GPSR2_OFFSET 0x020
#define GPSR3_OFFSET 0x118
#define GPCR0_OFFSET 0x024
#define GPCR1_OFFSET 0x028
#define GPCR2_OFFSET 0x02C
#define GPCR3_OFFSET 0x124
extern "C" {
typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
#define NTKERNELAPI
NTKERNELAPI
PVOID
MmMapIoSpace (
IN PHYSICAL_ADDRESS PhysicalAddress,
IN ULONG NumberOfBytes,
IN BOOLEAN CacheEnable
);
NTKERNELAPI
VOID
MmUnmapIoSpace (
IN PVOID BaseAddress,
IN ULONG NumberOfBytes
);
} // extern "C"
CGpio::CGpio()
{
PHYSICAL_ADDRESS PhysAddr;
PhysAddr.QuadPart = GPIO_BASE;
m_reg_base = (PUCHAR)MmMapIoSpace( PhysAddr, GPIO_SIZE, FALSE );
m_gplr[0] = (PULONG)(m_reg_base + GPLR0_OFFSET);
m_gplr[1] = (PULONG)(m_reg_base + GPLR1_OFFSET);
m_gplr[2] = (PULONG)(m_reg_base + GPLR2_OFFSET);
m_gplr[3] = (PULONG)(m_reg_base + GPLR3_OFFSET);
m_gpdr[0] = (PULONG)(m_reg_base + GPDR0_OFFSET);
m_gpdr[1] = (PULONG)(m_reg_base + GPDR1_OFFSET);
m_gpdr[2] = (PULONG)(m_reg_base + GPDR2_OFFSET);
m_gpdr[3] = (PULONG)(m_reg_base + GPDR3_OFFSET);
m_gpsr[0] = (PULONG)(m_reg_base + GPSR0_OFFSET);
m_gpsr[1] = (PULONG)(m_reg_base + GPSR1_OFFSET);
m_gpsr[2] = (PULONG)(m_reg_base + GPSR2_OFFSET);
m_gpsr[3] = (PULONG)(m_reg_base + GPSR3_OFFSET);
m_gpcr[0] = (PULONG)(m_reg_base + GPCR0_OFFSET);
m_gpcr[1] = (PULONG)(m_reg_base + GPCR1_OFFSET);
m_gpcr[2] = (PULONG)(m_reg_base + GPCR2_OFFSET);
m_gpcr[3] = (PULONG)(m_reg_base + GPCR3_OFFSET);
}
CGpio::~CGpio()
{
MmUnmapIoSpace( m_reg_base, GPIO_SIZE );
}
CGpio::PinDirection CGpio::GetPinDirection( int pin ) const
{
int idx = pin / 32;
int shift = pin % 32;
if ( idx < 0 && idx > 3 )
return unknown;
return *(m_gpdr[idx]) & (1 << shift) ? out : in;
}
int CGpio::SetPinDirection( int pin, PinDirection dir )
{
int idx = pin / 32;
int shift = pin % 32;
if ( idx < 0 && idx > 3 )
return - 1;
if ( dir == in )
*(m_gpdr[idx]) &= ~(1 << shift);
else
*(m_gpdr[idx]) |= 1 << shift;
return 0;
}
int CGpio::GetPinValue( int pin ) const
{
int idx = pin / 32;
int shift = pin % 32;
if ( idx < 0 && idx > 3 )
return -1;
return (*(m_gplr[idx]) >> shift) & 1;
}
int CGpio::SetPinValue( int pin, int value )
{
if ( GetPinDirection( pin ) != out )
return -1;
int idx = pin / 32;
int shift = pin % 32;
if ( idx < 0 && idx > 3 )
return -1;
if ( value )
*(m_gpsr[idx]) = (1 << shift);
else
*(m_gpcr[idx]) = (1 << shift);
return 0;
}
Поделиться1392008-09-01 18:30:40
Ето список, чиво табе нада? %)
Поделиться1402008-09-01 19:11:11
это врядли... хи