پاسخ : دانلود کتابخانه های مختلف برای میکروهای STM
کتابخانه max6675 که از avr تبدیلش کردم برای stm32 . تست شده جواب میده
کتابخانه max6675 که از avr تبدیلش کردم برای stm32 . تست شده جواب میده
#include "stm32f1xx_hal.h"
#include "main.h"
#include "fatfs.h"
#include "ILI932x.h"
#include "Touch.h"
#include "define.h"
//HAL_GPIO_WritePin(GPIOE, GPIO_PIN_2,GPIO_PIN_SET)
extern float READ_ADC(char PIN);
void MAX6675_Init(void){
HAL_GPIO_WritePin(GPIOB,MAX_CS_Pin,SET);
}
//**********************************************************************************
float gettemp(){ //Temperatur holen.
char bite = 0, bitnr = 12; //Variablen
char foo1 = 0;
int so_data = 0;
float TC;
HAL_GPIO_WritePin(GPIOB,MAX_CS_Pin,RESET);
HAL_Delay(10);
HAL_GPIO_WritePin(GPIOB,MAX_CS_Pin,SET);
HAL_Delay(250);
HAL_GPIO_WritePin(GPIOB,MAX_CS_Pin,RESET); //CS_Port &= ~(1 << CS);
for(foo1 = 0 ; foo1 < 16 ; foo1++){
bite = 15 - foo1;
HAL_GPIO_WritePin(GPIOB,MAX_CLK_Pin,SET); // SCK_Port |= (1 << SCK),delay_us(100);
if((bite <= 14) && (bite >= 3)){
if(HAL_GPIO_ReadPin(GPIOE,MAX_DIN_Pin)==1){ //WENN SO 1 ist, dann...
bitnr--; //zählen wir runter...
so_data |= (1 << bitnr); // und schieben eine 1 an bit x
}else{ //WENN dem NICHT so ist, dann...
bitnr--; //zählen wir runter...
so_data &= ~(1 << bitnr); //und schieben eine 0 an bit x
}
}else{ //weis au nimmer, was das soll.
bitnr = 12;
}
HAL_GPIO_WritePin(GPIOB,MAX_CLK_Pin,RESET),HAL_Delay(1); //SCK LO
}
HAL_GPIO_WritePin(GPIOB,MAX_CS_Pin,SET);
TC=so_data*0.25;
return TC; //Das ist doch mal was ;D
}
//**********************************************************************************
//float readFahrenheit(void) {
// return MAX6675_read(0) * 9.0/5.0 + 32;
//}
دیدگاه