/*
 * MISC.h
 *
 *  Created on: Dec 15, 2020
 *      Author: user
 */

#ifndef MISC_H_
#define MISC_H_

#include "main.h"
#include "usart.h"
//#include "crc.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "gpio.h"
//#include <globals.h>

#define IWDG_T04 {IWDG->KR=0xCCCC; IWDG->KR=0x5555; IWDG->PR=3; HAL_Delay(10);IWDG->KR=0xAAAA;}
#define IWDG_T02 {IWDG->KR=0xCCCC; IWDG->KR=0x5555; IWDG->PR=2; HAL_Delay(10);IWDG->KR=0xAAAA;}
#define IWDG_T32 {IWDG->KR=0xCCCC; IWDG->KR=0x5555; IWDG->PR=7; HAL_Delay(10);IWDG->KR=0xAAAA;}
#define IWDG_RES {IWDG->KR=0xAAAA;}


uint8_t swapBitsInByte(uint8_t x, uint8_t p1,uint8_t p2, uint8_t n);
uint16_t CRC16HW_modbus(char* buf , int len);
uint16_t CRC16SW_modbus(char* buf , int len);
uint8_t JOYSTICK(void);
uint8_t JOYSTICK_S(void);
int FSCANF(UART_HandleTypeDef *huart, uint8_t *buf);
int FPRINTF(UART_HandleTypeDef *huart, const char *str, ...);

uint8_t RDC_TEST(uint8_t G);

void GO_MENU(void);

void PWM_INIT(void);
void PWM_ADJ(int wypelnienie);

#endif /* MISC_H_ */
