本文整理汇总了C++中set_pin函数的典型用法代码示例。如果您正苦于以下问题:C++ set_pin函数的具体用法?C++ set_pin怎么用?C++ set_pin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_pin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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 */
}
}
示例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);
}
示例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);
}
}
示例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
}
示例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;
}