NEED A PERFECT PAPER? PLACE YOUR FIRST ORDER AND SAVE 15% USING COUPON:

Functional Programming Code Editing. Directions Begin your work by accessing the Project Thermostat Lab Guide PDF document. While this document was written

Click here to Order a Custom answer to this Question from our writers. It’s fast and plagiarism-free.

Functional Programming Code Editing. Directions Begin your work by accessing the Project Thermostat Lab Guide PDF document. While this document was written for a Windows interface, the tools can be used on Mac or Linux as well. To accomplish the work outlined in the guide, you will need the following:  TI CC3220x LAUNCHXL TI Code Composer Studio (installed) USB connection between the PC and board Specifically, you must address the following rubric criteria:  Develop code for all of the specified functionality. Remember, the goals of this project include reading room temperature, indicating the result via LED output, increasing or decreasing the set temperature, and simulating the data being sent to a server. Create code that initializes the timer and uses it to drive specified actions. This involves two steps, both the initializing of the timer and then its use in running an action. Create code that uses interrupt to detect button presses. This involves two steps, both the detection of the button presses and then using the result to run an action. Create code to initialize the I2C peripheral and use it to read the temperature sensor. This code must both initialize the I2C peripheral and then read the temperature sensor correctly. Create code to initialize the GPIO peripheral and use it. Remember that the GPIO is involved in indicating the output of the temperature via LED and setting the temperature with two different buttons (one to increase and one to decrease temperature). Create code to initialize the UART peripheral and output specified data. The UART should be used to simulate data being sent to the server. Be careful to ensure that the UART is initialized to the correct baud rate and serial configuration. Implement (in code) the task scheduler functionality. This should match the specifications described by the Project Thermostat Lab Guide /*
* Copyright (c) 2015-2020, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/*
* ======== gpiointerrupt.c ========
*/

#include

#include

/* For usleep() */

#include

/* Driver Header files */

#include

/* Driver configuration */

#include “ti_drivers_config.h”

#include

#include

#include

#include

// I2C Global Variables

static const struct {
uint8_t address;
uint8_t resultReg;

char *id;
} sensors[3] = {
{ 0x48, 0x0000, “11X” },
{ 0x49, 0x0000, “116” },
{ 0x41, 0x0001, “006” }
};
uint8_t txBuffer[1];
uint8_t rxBuffer[2];
I2C_Transaction i2cTransaction;
// Driver Handles – Global variables
I2C_Handle i2c;
// Make sure you call initUART() before calling this function.

void initI2C(void)
{
int8_t i, found;
I2C_Params i2cParams;

DISPLAY(snprintf(output, 64, “Initializing I2C Driver – “));

// Init the driver

I2C_init();
// Configure the driver

I2C_Params_init(&i2cParams);
i2cParams.bitRate = I2C_400kHz;
// Open the driver
i2c = I2C_open(CONFIG_I2C_0, &i2cParams);

if (i2c == NULL)
{
DISPLAY(snprintf(output, 64, “Failednr”));

while (1);
}
DISPLAY(snprintf(output, 32, “Passednr”));
// Boards were shipped with different sensors.
// Welcome to the world of embedded systems.
// Try to determine which sensor we have.
// Scan through the possible sensor addresses
/* Common I2C transaction setup */
i2cTransaction.writeBuf = txBuffer;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxBuffer;
i2cTransaction.readCount = 0;
found = false;

for (i=0; i<3; ++i) { i2cTransaction.slaveAddress = sensors[i].address; txBuffer[0] = sensors[i].resultReg; DISPLAY(snprintf(output, 64, "Is this %s? ", sensors[i].id)); if (I2C_transfer(i2c, &i2cTransaction)) { DISPLAY(snprintf(output, 64, "Foundnr")); found = true; break; } DISPLAY(snprintf(output, 64, "Nonr")); } if(found) { DISPLAY(snprintf(output, 64, "Detected TMP%s I2C address: %xnr", sensors[i].id, i2cTransaction.slaveAddress)); } else { DISPLAY(snprintf(output, 64, "Temperature sensor not found, contact professornr")); } } int16_t readTemp(void) { Int j; int16_t temperature = 0; i2cTransaction.readCount = 2; if (I2C_transfer(i2c, &i2cTransaction)) { /* * Extract degrees C from the received data; * see TMP sensor datasheet */ temperature = (rxBuffer[0] << 8) | (rxBuffer[1]); temperature *= 0.0078125; /* * If the MSB is set '1', then we have a 2's complement * negative value which needs to be sign extended */ if (rxBuffer[0] & 0x80) { temperature |= 0xF000; } } else { DISPLAY(snprintf(output, 64, "Error reading temperature sensor (%d)nr",i2cTransaction.status)); DISPLAY(snprintf(output, 64, "Please power cycle your board by unplugging USB and plugging back in. nr")); } return temperature; } #define DISPLAY(x) UART_write(uart, &output, x); // UART Global Variables Char output[64]; Int bytesToSend; // Driver Handles - Global variables UART_Handle uart; void initUART(void) { UART_Params uartParams; // Init the driver UART_init(); // Configure the driver UART_Params_init(&uartParams); uartParams.writeDataMode = UART_DATA_BINARY; uartParams.readDataMode = UART_DATA_BINARY; uartParams.readReturnMode = UART_RETURN_FULL; uartParams.baudRate = 115200; // Open the driver uart = UART_open(CONFIG_UART_0, &uartParams); if (uart == NULL) { /* UART_open() failed */ while (1); } } // Driver Handles - Global variables Timer_Handle timer0; volatile unsigned char TimerFlag = 0; void timerCallback(Timer_Handle myHandle, int_fast16_t status) { TimerFlag = 1; } void initTimer(void) { Timer_Params params; // Init the driver Timer_init(); // Configure the driver Timer_Params_init(&params); params.period = 1000000; params.periodUnits = Timer_PERIOD_US; params.timerMode = Timer_CONTINUOUS_CALLBACK; params.timerCallback = timerCallback; // Open the driver timer0 = Timer_open(CONFIG_TIMER_0, &params); if (timer0 == NULL) { /* Failed to initialized timer */ while (1) {} } if (Timer_start(timer0) == Timer_STATUS_ERROR) { /* Failed to start timer */ while (1) {} } } /* * ======== gpioButtonFxn0 ======== * Callback function for the GPIO interrupt on CONFIG_GPIO_BUTTON_0. * * Note: GPIO interrupts are cleared prior to invoking callbacks. */ void gpioButtonFxn0(uint_least8_t index) { /* Toggle an LED */ GPIO_toggle(CONFIG_GPIO_LED_0); } /* * ======== gpioButtonFxn1 ======== * Callback function for the GPIO interrupt on CONFIG_GPIO_BUTTON_1. * This may not be used for all boards. * * Note: GPIO interrupts are cleared prior to invoking callbacks. */ void gpioButtonFxn1(uint_least8_t index) { /* Toggle an LED */ } // the setup routine runs once when you press reset: void setup() { // initialize the digital pin as an output. GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD); } /* * ======== mainThread ======== */ void *mainThread(void *arg0) { /* Call driver init functions */ GPIO_init(); /* Configure the LED and button pins */ GPIO_setConfig(CONFIG_GPIO_LED_0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW); GPIO_setConfig(CONFIG_GPIO_BUTTON_0, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING); /* Turn on LED */ GPIO_write(CONFIG_GPIO_LED_0, CONFIG_GPIO_LED_ON); /* Install Button callback */ GPIO_setCallback(CONFIG_GPIO_BUTTON_0, gpioButtonFxn0); /* Enable interrupts */ GPIO_enableInt(CONFIG_GPIO_BUTTON_0); /* * If more than one input pin is available for your device, interrupts * will be enabled on CONFIG_GPIO_BUTTON1. */ if (CONFIG_GPIO_BUTTON_0 != CONFIG_GPIO_BUTTON_1) { /* Configure BUTTON1 pin */ GPIO_setConfig(CONFIG_GPIO_BUTTON_1, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING); /* Install Button callback */ GPIO_setCallback(CONFIG_GPIO_BUTTON_1, gpioButtonFxn1); GPIO_enableInt(CONFIG_GPIO_BUTTON_1); } return (NULL); }

Place your order now for a similar assignment and have exceptional work written by one of our experts, guaranteeing you an A result.

Need an Essay Written?

This sample is available to anyone. If you want a unique paper order it from one of our professional writers.

Get help with your academic paper right away

Quality & Timely Delivery

Free Editing & Plagiarism Check

Security, Privacy & Confidentiality