コード例 #1
0
/*
 * Initialise the MCP39F511 energy monitor
 */
bool MCP39F511Interface::initialise() {
	mcp_comms = new MCP39F511Comms(this);
	/* Ensure we are notified when a transaction has completed */
	connect(mcp_comms, SIGNAL(transactionComplete(Mcp39F511Transaction)), this, SLOT(transactionComplete(Mcp39F511Transaction)));
	if(!mcp_comms->initialise()) {
		return false;
	}
	
    outputTransactionId = 0;
	energyCounterTransactionId = 0;
	recordTransactionId = 0;
	calibrationTransactionId = 0;
	config1TransactionId = 0;
	config2TransactionId = 0;
	compPeriphTransactionId = 0;
    factoryResetId = 0;
    readAllRegistersId = 0;
    
    /* Setup PWM first so readAllRegisters() doesn't overwrite
       registers that have been configured whilst its in the queue
       to be sent to the chip. */
    setupPWM(MCP_SOUNDER_FREQUENCY, MCP_SOUNDER_PWM_DUTY_CYLCE);
	readAllRegistersId = readAllRegisters();
    initialisationInProgress = true;
	return true;
}
コード例 #2
0
ファイル: lab4part2.c プロジェクト: expectomas/lab4part1
int main(void)
{
	unsigned constrained = 0, shutOffBuzzer = 0;
	
	//Set GPIO Pins
	if(!shutOffBuzzer)
		DDRB|=0b00100000; //PIN 13 output to buzzer
	
	DDRB|=0b00001000;

	sei();
		
	setupADC();
	setupPWM();
	startPWM();
	
	count=0;
    InitTimer0();
	StartTimer0();
	
	while(1)
    {	
		if(state)
			pwm_val = remap(adc_val,100,900);
		else
		{
		//0-255 steps for tone strength
			constrained = remap(adc_val,619,890);			
		//Output tone
			tone(constrained);
		}	
    }
}
コード例 #3
0
ファイル: labs4.1.c プロジェクト: Absherr/controlsystems
int main(void)
{
	setupTimer();
	setupPWM();
	DDRB = 0xFF;
    while(1)
    {}
}
コード例 #4
0
ファイル: SchedMain.c プロジェクト: horsetailfiddlehead/ee478
void systemSetup(GlobalState *data) {

    rs232Setup2(); // configure USART2
    rs232Setup1(); // configure USART1
    i2CSetup();
    RFIDSetup();

#if FRONT_NOT_BACK
    initSPI1();
    initLCD();
    keypadSetup(); // configure keypad
    setupPWM();
#else
    LEDSetup();
#endif
    data->myRequestStatus = 0;
    data->displayPage = 0;
    data->keyFlag = FALSE;
    data->displayedKey = FALSE;
    data->keyPress = -1;
    data->cursorPos = 0;
    // Select Game Menu
    data->mode = -1;
    data->game = -1;
    // Find better way to do this
    data->mainMenuSpots[0] = 40;
    data->mainMenuSpots[1] = 80;
    data->mainMenuSpots[2] = 120;
    data->getInventory = FALSE;
    data->xbeeFlag = FALSE;
    data->goBack = FALSE;
    // Game Related Globals
    data->keyStatus = -1;
    memset(data->selectMove, 0, sizeof (int) * 4 * 3);
    data->selectMove[0][1] = 10;
    data->cardSelect[0] = 1;
    data->cardSelect[1] = 0;
    data->cardSelect[2] = 0;
    data->cardSelect[3] = 0;
    data->firstTime = TRUE;
    data->updateLEDFlag = TRUE;
    data->lastCards = 0;
    data->readCard = 0;
    data->dataBlockNum = 0;
    data->dataSlotNum = 0;
    memset(data->dataBlock, 0, sizeof (char) * CARDBLOCKSIZE);
    data->runGetUpdatedCards = FALSE;
    data->gotI2C = 0;
    data->sendI2C = 0;
    data->displayPage = 0;
    data->newDisplay = 0;
    data->newGame = 1;
    data->newKeyboard = 1;
    data->doneKeyboard = 0;
    OpenTimer0(TIMER_INT_OFF & T0_SOURCE_INT & T0_PS_1_32);

    return;
}
コード例 #5
0
static void led_init()
{
	RCC_APB1ENR |= RCC_APB1ENR_TIM3EN;
	RCC_AHBENR |= RCC_AHBENR_GPIOBEN;

	gpio_mode_setup(LED_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, LED_R_PIN | LED_G_PIN | LED_B_PIN);
	gpio_set_output_options(LED_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_25MHZ, LED_R_PIN | LED_G_PIN | LED_B_PIN);

	setupPWM();
}
コード例 #6
0
void onBlinkTimer()
{
	if (g_blinkCount > 0)
	{
		gpio_toggle(LED_PORT, LED_R_PIN);
		--g_blinkCount;
	} else
	{
		swTimer_unRegisterFromTimer(onBlinkTimer);
		g_isRedBlinking = false;
		setupPWM();
	}
}
コード例 #7
0
void initApplication(void)
{
    unsigned int address = currentVersion->baseAddress;
    setupPWM();

    for (unsigned int i = 0; i < NO_OF_CHANNELS; i++)
    {
        digitalWrite(outputPins[i], 0);
        pinMode(outputPins[i], OUTPUT);
        channels[i] = new Channel(i, address+16+i*256);
    }

    unsigned int initZeit = memMapper.getUInt8(P_InitZeit + address);
    Timeout startupDelay;
    if (initZeit)
    {
        startupDelay.start(initZeit);
        while (!startupDelay.expired())
        {
            waitForInterrupt();
        }
    }

/*  no yet used
    unsigned int telegrUnbegr = memMapper.getUInt8(PD_TelegrUnbegr + address);
    unsigned int telegrUebZeit = memMapper.getUInt16(P_TelegrUebZeit + address);
*/

    inBetrieb = memMapper.getUInt8(P_InBetrieb + address);
    inBetriebValue_0 = memMapper.getUInt8(P_InBetriebValue_0 + address);
    inBetriebZeit = memMapper.getUInt16(P_InBetriebZeit + address);

    if(inBetrieb != 255) {
    	inBetriebTimeout.start(1);
    }

    unsigned int einerFuerAlle = memMapper.getUInt8(t_EinerFuerAlle + address);

    msTimeout.start(1);
    timeoutTest.start(1);
}
コード例 #8
0
ファイル: main.cpp プロジェクト: omcaree/PiGimbalControl
int main() {
	openSerialPort();
	setupPWM();
	readSerialPort();
	return 0;
}