本文整理汇总了C++中set_pin函数的典型用法代码示例。如果您正苦于以下问题:C++ set_pin函数的具体用法?C++ set_pin怎么用?C++ set_pin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_pin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: set_number
void set_number(const struct pin_t *pins, uint8_t number)
{
set_pin(&pins[0], number & 0x1);
set_pin(&pins[1], number & 0x2);
set_pin(&pins[2], number & 0x4);
set_pin(&pins[3], number & 0x8);
}
开发者ID:MGraefe,项目名称:nixie-clock,代码行数:7,代码来源:nixie.c
示例2: usr_measure
uint16_t usr_measure(void)
{
static bool led = true;
volatile uint32_t result;
//enable USR
set_pin(USR_EN_PIN);
if (led)
{
set_pin(BRD_LED_PIN);
led = false;
}
else
{
clear_pin(BRD_LED_PIN);
led = true;
}
//delay 20us
nrf_delay_us(20);
NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Enabled;
NRF_ADC->EVENTS_END = 0;
NRF_ADC->TASKS_START = 1;
while (NRF_ADC->EVENTS_END == 0);
//unenable USR
clear_pin(USR_EN_PIN);
result = NRF_ADC->RESULT;
NRF_ADC->ENABLE = ADC_ENABLE_ENABLE_Disabled;
return result;
}
开发者ID:Callum-Sinclair,项目名称:Bike_monitoring_nrf,代码行数:29,代码来源:main.c
示例3: ping_ultrasonic
int ping_ultrasonic(int echo, int trig, int max_distance) //max_distance in cm
{//ping HC-SR04 ultrasonic range finder, 10us trigger pulse, sends eight 40kHz pulses
//int start_time;
int max_time; //max_time in system cycles
int flight_time;
//char message[100];
//sprintf(message, "bump");
//NU32_WriteUART1(message);
max_time = max_distance * 2320; //Distance(cm) = Time(us)/58, 40 core cycles per us, 58*40=2320
//start_time = ReadCoreTimer();
WriteCoreTimer(0);
set_pin(trig, HIGH);
while(ReadCoreTimer() < 1600){ //400 cycles at 40MHz, 10us trigger pulse
}
set_pin(trig, LOW);
//NU32_WriteUART1(message);
while(!get_pin(echo)){
}
//NU32_WriteUART1(message);
//start_time = ReadCoreTimer();
WriteCoreTimer(0);
while(get_pin(echo) && (ReadCoreTimer() < max_time)){
}
//flight_time = ReadCoreTimer() - start_time;
flight_time = ReadCoreTimer();
//sprintf(message, "%d\n", flight_time);
//NU32_WriteUART1(message);
return flight_time / 2320;
}
开发者ID:elsyd,项目名称:libnu32,代码行数:30,代码来源:Ultrasonic.c
示例4: configure_as_output
void LiquidCrystal::begin()
{
configure_as_output(rs_pin);
configure_as_output(enable_pin);
configure_as_output(rw_pin);
for(int i = 0; i < 4; i++)
configure_as_output(data_pins[i]);
set_pin(rs_pin, LOW);
set_pin(enable_pin, LOW);
set_pin(rw_pin, LOW);
write_bits(0x03);
etk::sleep_us(4500);
write_bits(0x03);
etk::sleep_us(500);
write_bits(0x03);
etk::sleep_us(250);
write_bits(0x02);
etk::sleep_ms(2);
write_bits(0x02);
etk::sleep_us(150);
write_bits(LCD_2LINE);
etk::sleep_us(150);
command(LCD_DISPLAYCONTROL);
clear();
command(LCD_ENTRYMODESET | LCD_ENTRYLEFT);
display();
}
开发者ID:supercamel,项目名称:ninjaskit_thermocouple,代码行数:31,代码来源:lcd.cpp
示例5: set_pin
void LiquidCrystal::pulse()
{
etk::sleep_us(1);
set_pin(enable_pin, HIGH);
etk::sleep_us(1);
set_pin(enable_pin, LOW);
etk::sleep_us(100);
}
开发者ID:supercamel,项目名称:ninjaskit_thermocouple,代码行数:8,代码来源:lcd.cpp
示例6: init_am27c
void init_am27c(void) {
init_am27c_ports();
set_pin(P_PGM, PGM, 1);
set_pin(P_CE, CE, 0);
set_pin(P_OE, OE, 1);
am27c_set_addr(0x0000);
}
开发者ID:sszachow,项目名称:eprom_reader,代码行数:9,代码来源:am27c.c
示例7: main
int main(void)
{
clock_setup();
spi2.begin();
configure_as_output({PB, 0});
set_pin({PB, 0}, true);
etk::sleep_ms(300);
//configure chip select pin
auto cs = gpio_pin(PA, 8);
configure_as_output(cs);
set_pin(cs, true);
//start LCD screen
lcd.begin();
etk::sleep_ms(500);
while(true)
{
lcd.set_cursor(0, 0);
lcd.print("Temp: ");
set_pin(cs, false);
union spidata
{
char bytes[4];
int32 data;
};
spidata data;
data.bytes[3] = spi2.read();
data.bytes[2] = spi2.read();
data.bytes[1] = spi2.read();
data.bytes[0] = spi2.read();
set_pin(cs, true);
lcd.set_cursor(2, 6);
int32 v = data.data;
if (v & 0x80000000)
v = 0xFFFFC000 | ((v >> 18) & 0x00003FFFF);
else
v >>= 18;
real_t deg_c = v;
deg_c *= 0.25;
lcd.print(deg_c, " C");
etk::sleep_ms(500);
}
开发者ID:supercamel,项目名称:ninjaskit_thermocouple,代码行数:55,代码来源:main.cpp
示例8: ht1632_write
void ht1632_write(uns8 mem_addr, uns8 data) {
uns8 count;
clear_pin(ht1632_cs1_port, ht1632_cs1_pin);
// send WR command
// send 1
set_pin (ht1632_data_port, ht1632_data_pin);
// pulse wr
clear_pin(ht1632_wr_port, ht1632_wr_pin);
set_pin (ht1632_wr_port, ht1632_wr_pin);
// send 0
clear_pin (ht1632_data_port, ht1632_data_pin);
// pulse wr
clear_pin(ht1632_wr_port, ht1632_wr_pin);
set_pin (ht1632_wr_port, ht1632_wr_pin);
// send 1
set_pin (ht1632_data_port, ht1632_data_pin);
// pulse wr
clear_pin(ht1632_wr_port, ht1632_wr_pin);
set_pin (ht1632_wr_port, ht1632_wr_pin);
// write mem addr, bits 6 -> 0
for(count = 0 ; count < 7 ; count++) {
if (test_bit(mem_addr, 6)) {
set_pin(ht1632_data_port, ht1632_data_pin);
} else {
clear_pin(ht1632_data_port, ht1632_data_pin);
}
//change_pin_var(ht1632_data_port, ht1632_data_pin, test_bit(mem_addr, 6));
// pulse wr
clear_pin(ht1632_wr_port, ht1632_wr_pin);
set_pin (ht1632_wr_port, ht1632_wr_pin);
// shift mem addr along
mem_addr = mem_addr << 1;
}
// write data, bits 0 -> 3 (different from mem addr format)
for(count = 0 ; count < 4 ; count++) {
change_pin_var(ht1632_data_port, ht1632_data_pin, test_bit(data, 0));
// pulse wr
clear_pin(ht1632_wr_port, ht1632_wr_pin);
set_pin (ht1632_wr_port, ht1632_wr_pin);
// shift mem addr along
data = data >> 1;
}
// reset CS
// set_pin(ht1632_cs1_port, ht1632_cs1_pin);
// delay_ms(1);
// clear_pin(ht1632_cs1_port, ht1632_cs1_pin);
set_pin(ht1632_cs1_port, ht1632_cs1_pin);
}
开发者ID:MotionReality,项目名称:picpack,代码行数:60,代码来源:ht1632.c
示例9: ht1632_fill2
void ht1632_fill2(uns8 colour) {
uns16 count;
ht1632_send_command(HT1632_CMD_LEDS_OFF);
clear_pin(ht1632_cs1_port, ht1632_cs1_pin);
// send WR command
// send 1
set_pin (ht1632_data_port, ht1632_data_pin);
// pulse wr
clear_pin(ht1632_wr_port, ht1632_wr_pin);
set_pin (ht1632_wr_port, ht1632_wr_pin);
// send 0
clear_pin (ht1632_data_port, ht1632_data_pin);
// pulse wr
clear_pin(ht1632_wr_port, ht1632_wr_pin);
set_pin (ht1632_wr_port, ht1632_wr_pin);
// send 1
set_pin (ht1632_data_port, ht1632_data_pin);
// pulse wr
clear_pin(ht1632_wr_port, ht1632_wr_pin);
set_pin (ht1632_wr_port, ht1632_wr_pin);
// send mem address of zero
clear_pin(ht1632_data_port, ht1632_data_pin);
// write mem addr, bits 6 -> 0
for(count = 0 ; count < 7 ; count++) {
//change_pin_var(ht1632_data_port, ht1632_data_pin, test_bit(mem_addr, 6));
// pulse wr
clear_pin(ht1632_wr_port, ht1632_wr_pin);
set_pin (ht1632_wr_port, ht1632_wr_pin);
// shift mem addr along
}
if (colour) {
set_pin(ht1632_data_port, ht1632_data_pin);
} else {
clear_pin(ht1632_data_port, ht1632_data_pin);
}
// we need to toggle 384 times
for(count = 0 ; count < 384 ; count++) {
// pulse wr
clear_pin(ht1632_wr_port, ht1632_wr_pin);
set_pin (ht1632_wr_port, ht1632_wr_pin);
// shift mem addr along
}
// reset CS
set_pin(ht1632_cs1_port, ht1632_cs1_pin);
ht1632_send_command(HT1632_CMD_LEDS_ON);
}
开发者ID:MotionReality,项目名称:picpack,代码行数:60,代码来源:ht1632.c
示例10: am27c_get_data
unsigned char am27c_get_data(unsigned short addr) {
unsigned char data = 0x00;
am27c_set_addr(addr);
delay_us(1);
set_pin(P_OE, OE, 0);
delay_us(1);
data = read_data();
set_pin(P_OE, OE, 1);
return data;
}
开发者ID:sszachow,项目名称:eprom_reader,代码行数:12,代码来源:am27c.c
示例11: handle_mgcoge3un_reset
/*
* For mgcoge3ne boards, the mgcoge3un control is controlled from
* a GPIO line on the PPC CPU. If bobcatreset is set the line
* will toggle once what forces the mgocge3un part to restart
* immediately.
*/
static void handle_mgcoge3un_reset(void)
{
char *bobcatreset = getenv("bobcatreset");
if (bobcatreset) {
if (strcmp(bobcatreset, "true") == 0) {
puts("Forcing bobcat reset\n");
set_pin(0, 0x00000004, 3); /* clear PD29 (reset arm) */
udelay(1000);
set_pin(1, 0x00000004, 3);
} else
set_pin(1, 0x00000004, 3); /* don't reset arm */
}
}
开发者ID:eballetbo,项目名称:u-boot,代码行数:19,代码来源:km82xx.c
示例12: sure_2416_setup
void sure_2416_setup() {
//serial_print_str("Setting up 2416\n");
make_output(sure_2416_cs1_port, sure_2416_cs1_pin);
make_output(sure_2416_data_port, sure_2416_data_pin);
make_output(sure_2416_wr_port, sure_2416_wr_pin);
make_output(sure_2416_rd_port, sure_2416_rd_pin);
set_pin(sure_2416_wr_port, sure_2416_wr_pin);
set_pin(sure_2416_rd_port, sure_2416_rd_pin);
set_pin(sure_2416_cs1_port, sure_2416_cs1_pin);
}
开发者ID:MotionReality,项目名称:picpack,代码行数:14,代码来源:sure_2416.c
示例13: set_pin
void HardwareSerial::end() {
//set the pins to read (high Z)
if(port==0) {
set_pin(0,0); //TX0->GPIO
set_pin(1,0); //RX0->GPIO
gpio_set_read(0);
gpio_set_read(1);
} else {
set_pin(8,0); //TX1->GPIO
set_pin(9,0); //RX1->GPIO
gpio_set_read(8);
gpio_set_read(9);
}
}
开发者ID:kwan3217,项目名称:Loginator,代码行数:14,代码来源:Serial.cpp
示例14: mrf24j40_setup_io
void mrf24j40_setup_io() {
#ifndef __PIC32MX__
make_input(mrf24j40_int_port, mrf24j40_int_pin);
set_pin(mrf24j40_cs_port, mrf24j40_cs_pin); // keep high
make_output(mrf24j40_cs_port, mrf24j40_cs_pin);
#endif
#ifdef __PIC32MX__
SPI_init(); // init SPI default (2 on PIC32-PINGUINO)
// only called here for test
// will be called later in main32.c
#ifndef PIC32_PINGUINO_220
//pinmode(13,OUTPUT); // CLK
//pinmode(11,OUTPUT); // SDO
//pinmode(12,INPUT); // SDI
ZIGRESETOUT; // macro for RESET
ZIGCSOUT; // macro for CS
ZIGINTIN; // interrupt (not yet implemented)
#else
ZIGRESETOUT; // macro for RESET
ZIGCSOUT; // macro for CS
#endif
ZIGRESET=0;
ZIGCS=1;
ZIGRESET=1;
Delayms(100);
#endif
}
开发者ID:AgustinParmisano,项目名称:pinguino32,代码行数:28,代码来源:mrf24j40.c
示例15: mrf24j40_long_addr_read
uns8 mrf24j40_long_addr_read(uns16 addr){
uns8 result;
#ifndef __PIC32MX__
clear_pin(mrf24j40_cs_port, mrf24j40_cs_pin);
addr = addr & 0b0000001111111111; // <9:0> bits
addr = addr << 5;
set_bit(addr, 15); // long addresss
spi_hw_transmit(addr >> 8);
spi_hw_transmit(addr & 0x00ff);
result = spi_hw_receive();
set_pin(mrf24j40_cs_port, mrf24j40_cs_pin);
#endif
#ifdef __PIC32MX__
ZIGCS=0;
addr=((addr<<1)&0x7FE)|0x800;
addr<<=4;
SPI_write(addr>>8);
SPI_write(addr);
result=SPI_read();
ZIGCS=1;
#endif
return result;
}
开发者ID:AgustinParmisano,项目名称:pinguino32,代码行数:26,代码来源:mrf24j40.c
示例16: mrf24j40_long_addr_write
void mrf24j40_long_addr_write(uns16 addr, uns8 data){
#ifndef __PIC32MX__
clear_pin(mrf24j40_cs_port, mrf24j40_cs_pin);
addr = addr & 0b0000001111111111; // <9:0> bits
addr = addr << 5;
set_bit(addr, 15); // long addresss
set_bit(addr, 4); // set for write
spi_hw_transmit(addr >> 8 );
spi_hw_transmit(addr & 0x00ff);
spi_hw_transmit(data);
set_pin(mrf24j40_cs_port, mrf24j40_cs_pin);
#endif
#ifdef __PIC32MX__
ZIGCS=0;
addr=((addr<<1)&0x7FF)|0x801;
addr<<=4;
SPI_write(addr>>8);
SPI_write(addr);
SPI_write(data);
ZIGCS=1;
#endif
}
开发者ID:AgustinParmisano,项目名称:pinguino32,代码行数:27,代码来源:mrf24j40.c
示例17: switchOnVibration
bool switchOnVibration(uint8_t time)
{
set_pin(VIBRATING_MOTOR_PIN);
vibratingTime = time * 10;
startingTime = vabrationCnt;
return 0;
}
开发者ID:oleg-Shipitko,项目名称:RESET,代码行数:7,代码来源:Manipulators.c
示例18: main
int main(int argc, char *argv[])
{
int pin;
if(argc < 2)
{
printf("USAGE: setlp0pin pin#\n");
exit(1);
}
pin = atoi(argv[1]);
if (pin_init_user(LPT1) < 0)
exit(0);
pin_output_mode(LP_DATA_PINS | LP_SWITCHABLE_PINS);
if(pin < 0) // clear requested
{
pin = pin * -1;
clear_pin(LP_PIN[pin]);
printf("pin# %d cleared\n", pin);
}
else
{
set_pin(LP_PIN[pin]);
printf("pin# %d set. Run \"setlp0pin -%d\" to clear pin# %d\n", pin, pin, pin);
}
return 0;
}
开发者ID:Baljan,项目名称:cafesys-fork,代码行数:27,代码来源:setlp0pin.c
示例19: rf01_init
void rf01_init(void)
{
unsigned char i;
GPIO_InitTypeDef GPIO_InitStructure;
/* GPIOD Periph clock enable */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
/* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = SDI | SCK| CS;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = SDO;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
//GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOB, &GPIO_InitStructure);
set_pin(GPIOB,CS);
for (i=0; i<11; i++)
/*** !!!!!!!!!!!!!!!!!!!!!!!!! DELAY ******************/
delay_ms(10); // wait until POR done
rf01_trans(0xC2E0); // AVR CLK: 10MHz
rf01_trans(0xC42B); // Data Filter: internal
rf01_trans(0xCE88); // FIFO mode
rf01_trans(0xC6F7); // AFC settings: autotuning: -10kHz...+7,5kHz
rf01_trans(0xE000); // disable wakeuptimer
rf01_trans(0xCC00); // disable low duty cycle
/* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOD, &GPIO_InitStructure);
#if RF01_UseIRQ == 1
// jeœli obs³uga na przerwaniach
RF01_status.Rx = 0;
RF01_status.New = 0;
RFM01Irq_Init();
#endif
blinkLED();
}
开发者ID:pawelc06,项目名称:STM32F407_WEB_SERVER,代码行数:60,代码来源:rf01.c
示例20: set_event
void set_event(uint8_t event_number)
{
uint8_t which_pin = events[event_number].pin;
actual_events[which_pin] = event_number;
switch(which_pin)
{
case EXP0_PC2:
case EXP1_PD4:
case EXP2_PD7:
case EXP3_PB0:
set_pin(which_pin, events[event_number].pin_state);
break;
case PWM0_PD6:
case PWM1_PD5:
// not implemented yet case PWM2_PB1:
// not implemented yet case PWM3_PD3:
run_pwm(which_pin, &events[event_number]);
break;
default:break;
}
int32_t time = current_time();
// event_time
char formatted_date[30];
timeToString(time, formatted_date);
send_string(formatted_date);
send_string(" ");
print_event(event_number);
}
开发者ID:snegtec,项目名称:MeropiModerariModuli,代码行数:35,代码来源:events.c
注:本文中的set_pin函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论