mikrokontrollersystemer-pro.../prosjekt.X/header.h

70 lines
2.3 KiB
C
Raw Normal View History

2024-03-06 14:16:01 +00:00
/* Microchip Technology Inc. and its subsidiaries. You may use this software
* and any derivatives exclusively with Microchip products.
*
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
* EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
* WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
* PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
* WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.
*
* IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
* INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
* WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
* BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
* FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS
* IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF
* ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
*
* MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
* TERMS.
*/
/*
* File:
* Author:
* Comments:
* Revision history:
*/
2024-03-06 14:22:40 +00:00
#define F_CPU 4000000UL
#define RTC_PERIOD (511)
#define DELAY_TIME 1000
#define USART3_BAUD_RATE(BAUD_RATE) ((float) (64*F_CPU /(16*(float)BAUD_RATE) )+0.5)
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <string.h>
#include <stdbool.h>
#include <stdio.h>
2024-03-06 14:16:01 +00:00
// This is a guard condition so that contents of this file are not included
// more than once.
#ifndef XC_HEADER_TEMPLATE_H
#define XC_HEADER_TEMPLATE_H
#include <xc.h> // include processor files - each processor file is guarded.
2024-03-06 14:22:40 +00:00
2024-03-06 14:27:54 +00:00
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
2024-03-06 14:16:01 +00:00
2024-03-06 14:27:54 +00:00
// TODO If C++ is being used, regular C code needs function names to have C
// linkage so the functions can be used by the c code.
2024-03-06 14:16:01 +00:00
2024-03-06 14:27:54 +00:00
#ifdef __cplusplus
2024-03-06 14:22:40 +00:00
}
2024-03-06 14:27:54 +00:00
#endif /* __cplusplus */
2024-03-06 14:16:01 +00:00
2024-03-06 14:27:54 +00:00
#endif /* XC_HEADER_TEMPLATE_H */
2024-03-06 14:16:01 +00:00
2024-03-11 14:48:20 +00:00
void USART3_init(void);
void USART3_sendChar(char c);
void USART3_sendString(char *str);
static int USART3_printChar(char c, FILE *stream);
2024-03-06 14:27:54 +00:00
uint16_t adcVal;
2024-03-11 14:48:20 +00:00
void led_init(void);
2024-03-06 14:27:54 +00:00
void ADC0_init(void);
uint16_t ADC0_read();
void ADC0_start(void);
2024-03-11 14:48:20 +00:00
bool ADC0_conversationDone(void);