本文整理汇总了C++中PIN_CLEAR函数的典型用法代码示例。如果您正苦于以下问题:C++ PIN_CLEAR函数的具体用法?C++ PIN_CLEAR怎么用?C++ PIN_CLEAR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PIN_CLEAR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spi_send
uint8_t
spi_send(uint8_t outdata)
{
DDR_CONFIG_IN(SOFT_SPI_MISO);
uint8_t j, indata = indata;
for(j = 0; j < 8; j++)
{
if(outdata & 0x80)
PIN_SET(SOFT_SPI_MOSI);
else
PIN_CLEAR(SOFT_SPI_MOSI);
PIN_SET(SOFT_SPI_SCK);
indata <<= 1;
if(PIN_HIGH(SOFT_SPI_MISO))
indata |= 1;
PIN_CLEAR(SOFT_SPI_SCK);
outdata <<= 1;
}
DDR_CONFIG_OUT(SOFT_SPI_MISO);
return indata;
}
示例2: hd44780_hw_init
void noinline hd44780_hw_init(void)
{
/* init io pins */
CTRL_OUTPUT();
#ifdef HAVE_LCDON
PIN_SET(LCDON);
#endif
PIN_CLEAR(HD44780_RS);
#ifndef HD44780_MULTIENSUPPORT
PIN_CLEAR(HD44780_EN1);
#endif
#ifdef HD44780_MULTIENSUPPORT
PIN_CLEAR(HD44780_EN1);
PIN_CLEAR(HD44780_EN2);
#endif
#ifdef HAVE_HD44780_RW
PIN_CLEAR(HD44780_RW);
#endif
PIN_CLEAR(HD44780_D4);
PIN_CLEAR(HD44780_D5);
PIN_CLEAR(HD44780_D6);
PIN_CLEAR(HD44780_D7);
DATA_OUTPUT();
#ifdef HD44780_BACKLIGHT_SUPPORT
PIN_CLEAR(HD44780_BL);
#endif
}
示例3: shift_nibble_out
void noinline shift_nibble_out(uint8_t data)
{
// HD44780DEBUG("try to send: %X\n", data);
uint8_t mask = 0x08;
for (uint8_t n = 4; n > 0; n--) // Do this for 4 databits
{
// HD44780DEBUG("send %i bit: %X\n", n, data & mask );
if (data & mask) // Set or reset data signal
PIN_SET(HD44780_2WIRE_D);
else
PIN_CLEAR(HD44780_2WIRE_D);
PIN_SET(HD44780_2WIRE_CLK);
LCD_DELAY();
PIN_CLEAR(HD44780_2WIRE_CLK);
mask >>= 1; // Shift right compare mask
}
// Clear data line, then do the last shift, Q7=1
// Always clear data line before the last shift
PIN_CLEAR(HD44780_2WIRE_D);
PIN_SET(HD44780_2WIRE_CLK);
LCD_DELAY();
PIN_CLEAR(HD44780_2WIRE_CLK);
}
示例4: leds_set_pin
static void leds_set_pin(leds_led_t led, bool on)
{
switch( led ){
case LED_0:
if( on ){
PIN_SET(LED_0);
}else{
PIN_CLEAR(LED_0);
}
break;
case LED_1:
if( on ){
PIN_SET(LED_1);
}else{
PIN_CLEAR(LED_1);
}
break;
case LED_2:
if( on ){
PIN_SET(LED_2);
}else{
PIN_CLEAR(LED_2);
}
break;
}
}
示例5: lome6_timersec
/*
* lome6 periodical countdown timer function
* counts down time in ~seconds since power button long is pressed (needed to prevent watchdog action)
* manages power on delay
*/
void lome6_timersec(void) {
if (iCountdownTimer > 0) {
iCountdownTimer--;
if (iCountdownTimer <= 0)
PIN_CLEAR(RELAIS_POWER);
}
// test power on delay counter
// if server already on, dont do anything
if (iPOD > 0 && PIN_HIGH(POWER_STATE)) {
iPOD--;
if (iPOD <= 0) {
PIN_SET(RELAIS_POWER);
_delay_ms(CONF_TIME2PRESS_POWER);
PIN_CLEAR(RELAIS_POWER);
}
}
}
示例6: main
int main(void)
{
uint8_t escaped = 0;
leds_init();
DDR_CONFIG_OUT(RS485_TX_PIN);
DDR_CONFIG_OUT(RS485_NRX_PIN);
PIN_CLEAR(RS485_TX_PIN);
PIN_CLEAR(RS485_NRX_PIN);
UBRR0 = UART_BAUD_SELECT(RS485_BITRATE,F_CPU);
UCSR0B |= (1<<TXEN0) | (1<<RXEN0);
UBRR1 = UART_BAUD_SELECT(RS485_BITRATE,F_CPU);
UCSR1B |= (1<<TXEN1) | (1<<RXEN1);
wdt_reset();
PIN_SET(RS485_TX_PIN);
PIN_SET(RS485_NRX_PIN);
while(1){
wdt_reset();
if( (UCSR1A & (1<<RXC1)) ){
uint8_t data = UDR1;
if( escaped ){
escaped = 0;
if( data == 'R' ){
wdt_enable(WDTO_2S);
while(1);
}
}else{
if( data == '\\' ){
escaped = 1;
continue;
}
}
UDR0 = data;
PIN_SET(RS485_TX_PIN);
PIN_SET(RS485_NRX_PIN);
//_delay_us(4);
leds_tx();
while( !(UCSR0A & (1<<TXC0)) );
UCSR0A |= (1<<TXC0);
leds_txend();
//_delay_us(4);
PIN_CLEAR(RS485_TX_PIN);
PIN_CLEAR(RS485_NRX_PIN);
}
if( (UCSR0A & (1<<RXC0)) ){
UDR1 = UDR0;
leds_rx();
while( !(UCSR1A & (1<<TXC1)) );
UCSR1A |= (1<<TXC1);
leds_rxend();
}
}
}
示例7: initMMC
// Initialize MMC card
unsigned char initMMC (void)
{
//raise SS and MOSI for 80 clock cycles
//SendByte(0xff) 10 times with SS high
//RAISE SS
int i;
// Port 5 Function Dir On/Off
// 5.1-Dout Out 0 - off 1 - On -> init in SPI_Init
// 5.2-Din Inp 0 - off 1 - On -> init in SPI_Init
// 5.3-Clk Out - -> init in SPI_Init
// 5.0-mmcCS Out 0 - Active 1 - none Active
/*
P5SEL |= 0x0E;
P5SEL &= ~0x11;
P5OUT |= 0x11;
P5DIR |= 0x1B;
*/
/*
PIN_SET(port5_attr.sel, 0x0e, PIN_HI);
PIN_CLEAR(port5_attr.sel, 0x01);
PIN_SET(port5_attr.dir, 0x0B, PIN_HI);
PIN_CLEAR(port5_attr.dir, 0x04);
port_set_attr(5, 0x0f, &port5_attr);
port_write(5, 0x01, PIN_HI);
*/
// PIN_SET(port5_attr.sel, 0x0e, PIN_HI);
#ifndef PORT_WRITE
mmcPower(MMC_ON);
MMC_PWR_PDIR |= MMC_CARD_PWR;
MMC_PWR_PSEL &= ~MMC_CARD_PWR;
// MMC_POUT |= MMC_CS;
CS_HIGH();
MMC_PDIR |= MMC_CS;
MMC_PSEL &= ~MMC_CS;
#else // !PORT_WRITE
PIN_SET (mmc_pwr_port_attr.dir, MMC_CARD_PWR, PIN_HI);
PIN_CLEAR(mmc_pwr_port_attr.sel, MMC_CARD_PWR);
port_set_attr(MMC_PWR_PORT, MMC_CARD_PWR, &mmc_pwr_port_attr);
mmcPower(MMC_ON);
PIN_CLEAR(mmc_port_attr.sel, MMC_CS);
PIN_SET (mmc_port_attr.dir, MMC_CS, PIN_HI);
port_set_attr(MMC_PORT, MMC_CS, &mmc_port_attr);
CS_HIGH();
//port_write(5, 0x01, PIN_HI);
#endif // !PORT_WRITE
// initSPI();
// SPI_init();
//initialization sequence on PowerUp
// CS_HIGH();
for(i=0;i<=9;i++)
spiSendByte(0xff);
mmc_error = MMC_SUCCESS;
return (mmc_GoIdle());
}
示例8: leds_init
void leds_init(void)
{
DDR_CONFIG_OUT(LED1);
DDR_CONFIG_OUT(LED2);
DDR_CONFIG_OUT(LED3);
PIN_CLEAR(LED1);
PIN_CLEAR(LED2);
PIN_CLEAR(LED3);
}
示例9: clear_shift_register
void clear_shift_register(void)
{
PIN_CLEAR(HD44780_2WIRE_D);
for (uint8_t a=7; a>0; a--)
{
PIN_SET(HD44780_2WIRE_CLK);
LCD_DELAY();
PIN_CLEAR(HD44780_2WIRE_CLK);
LCD_DELAY();
}
}
示例10: eltakoms_init
void eltakoms_init(void)
{
usart_init();
#if (USE_USART == 0 && defined(HAVE_RS485TE_USART0))
PIN_CLEAR(RS485TE_USART0); // disable RS485 transmitter for usart 0
#elif (USE_USART == 1 && defined(HAVE_RS485TE_USART1))
PIN_CLEAR(RS485TE_USART1); // disable RS485 transmitter for usart 1
#else
#warning no RS485 transmit enable pin defined
#endif
ELTAKOMS_DEBUG("init\n");
}
示例11: zbus_core_init
void
zbus_core_init(void)
{
/* Initialize the usart module */
usart_init();
/* Enable RX/TX Swtich as Output */
DDR_CONFIG_OUT(RS485_TX_PIN);
DDR_CONFIG_OUT(RS485_NRX_PIN);
usart(UCSR,B) = _BV(usart(RXCIE)) | _BV(usart(RXEN));
/* Default is reciever enabled*/
PIN_CLEAR(RS485_TX_PIN);
PIN_CLEAR(RS485_NRX_PIN);
}
示例12: sys_init
/* Инициализация портов */
void sys_init()
{
port_attr_t port_attr;
/* Настройка выхода на зелёный светодиод */
PIN_SET( port_attr.dir, GREEN_PIN, PIN_HI ); /* Направление на вывод */
PIN_CLEAR( port_attr.sel, GREEN_PIN ); /* Функция ввода/вывода */
port_set_attr( GREEN_PORT, GREEN_PIN, &port_attr );
port_write( GREEN_PORT, GREEN_PIN, PIN_LO ); /* По умолчанию гасим светодиод */
/* Настройка выхода на красный светодиод */
PIN_SET( port_attr.dir, RED_PIN, PIN_HI ); /* Направление на вывод */
PIN_CLEAR( port_attr.sel, RED_PIN ); /* Функция ввода/вывода */
port_set_attr( RED_PORT, RED_PIN, &port_attr );
port_write( RED_PORT, RED_PIN, PIN_LO ); /* По умолчанию гасим светодиод */
/* Настройка входа от геркона */
{ port_t gercon_port = 0x00;
event_type_t event_type = 0;
result_t res = ENOSYS;
port_reset_iflag( GERCON_PORT, GERCON_PIN );
PIN_CLEAR( port_attr.dir, GERCON_PIN ); /* Направление на ввод */
PIN_CLEAR( port_attr.sel, GERCON_PIN ); /* Функция ввода/вывода */
PIN_SET( port_attr.ie, GERCON_PIN, PIN_HI ); /* Разрешаем прерывания от кнопки */
PIN_SET( port_attr.ies, GERCON_PIN, PIN_HI ); /* Ловим изменение с высокого на низкий уровень */
port_set_attr( GERCON_PORT, GERCON_PIN, &port_attr );
port_read( GERCON_PORT, GERCON_PIN, &gercon_port );
/* Определение текущего состояния геркона */
if( PIN_IS_SET( gercon_port, GERCON_PIN) ) {
event_type = EV_TYPE_OPEN;
} else {
PIN_SET( port_attr.ies, GERCON_PIN, PIN_LO ); /* Ловим изменение с низкого на высокий уровень */
port_set_attr( GERCON_PORT, GERCON_PIN, &port_attr );
event_type = EV_TYPE_CLOSE;
}
res = event_emit( PRIORITY_LOW, event_type, 0 );
if( IS_ERROR(res) ) {
/* Не смогли начать работу, зажигаем красный светодиод */
port_write( RED_PORT, RED_PIN, PIN_HI );
}
}
return;
}
示例13: hd44780_hw_init
void noinline hd44780_hw_init(void)
{
HD44780DEBUG("starte HW init\n");
// set data direction to output & clear pins
CTRL_OUTPUT();
DATA_OUTPUT();
PIN_CLEAR(HD44780_2WIRE_CLK);
PIN_CLEAR(HD44780_2WIRE_D);
_delay_ms(50); // Delay for power up time
clear_shift_register();
HD44780DEBUG("HW init finished\n");
}
示例14: shift_data_out
void noinline
shift_data_out(uint8_t byte)
{
for (uint8_t a = 8; a > 0; a--)
{
if ((byte & (1 << (a - 1))) != 0)
PIN_SET(HD44780_SER_D);
else
PIN_CLEAR(HD44780_SER_D);
PIN_SET(HD44780_SER_CLK);
_delay_us(1);
PIN_CLEAR(HD44780_SER_CLK);
}
}
示例15: sys_init
/* Инициализация прикладного объекта */
void sys_init()
{
port_attr_t port_attr;
/* Настройка ножки светодиода */
PIN_SET( port_attr.dir, GREEN_LED, PIN_HI ); /* Направление на вывод */
PIN_CLEAR( port_attr.sel, GREEN_LED); /* Функция ввода/вывода */
PIN_CLEAR( port_attr.ie, GREEN_LED); /* Запрет прерываний */
port_set_attr( LED_PORT, GREEN_LED, &port_attr );
port_write( LED_PORT, GREEN_LED, PIN_LO );
atimer_set( ASYNC_TIMER , atimer_counter() + WAIT_PERIOD );
return;
}