diff --git a/eeprom_min.c b/eeprom_min.c --- a/eeprom_min.c +++ b/eeprom_min.c @@ -1,9 +1,11 @@ +#include +/* void Minimal_EEPROM_Unlock(void) { if((FLASH->PECR & FLASH_PECR_PELOCK) != RESET) { - /* Unlocking the Data memory and FLASH_PECR register access*/ + // Unlocking the Data memory and FLASH_PECR register access FLASH->PEKEYR = FLASH_PEKEY1; FLASH->PEKEYR = FLASH_PEKEY2; } @@ -11,7 +13,8 @@ void Minimal_EEPROM_Unlock(void) void Minimal_EEPROM_Lock(void) { - /* Set the PELOCK Bit to lock the data memory and FLASH_PECR register access */ + + // Set the PELOCK Bit to lock the data memory and FLASH_PECR register access FLASH->PECR |= FLASH_PECR_PELOCK; } @@ -41,7 +44,7 @@ FLASH_Status Minimal_FLASH_GetStatus(voi } } } - /* Return the FLASH Status */ + // Return the FLASH Status return FLASHstatus; } @@ -49,10 +52,10 @@ FLASH_Status Minimal_FLASH_WaitForLastOp { __IO FLASH_Status status = FLASH_COMPLETE; - /* Check for the FLASH Status */ + // Check for the FLASH Status status = Minimal_FLASH_GetStatus(); - /* Wait for a FLASH operation to complete or a TIMEOUT to occur */ + // Wait for a FLASH operation to complete or a TIMEOUT to occur while((status == FLASH_BUSY) && (Timeout != 0x00)) { status = Minimal_FLASH_GetStatus(); @@ -63,7 +66,7 @@ FLASH_Status Minimal_FLASH_WaitForLastOp { status = FLASH_TIMEOUT; } - /* Return the operation status */ + // Return the operation status return status; } @@ -84,4 +87,4 @@ void Minimal_EEPROM_ProgramWord(uint32_t // Return the Write Status return status; } - +*/ diff --git a/gpio.c b/gpio.c --- a/gpio.c +++ b/gpio.c @@ -23,7 +23,7 @@ void user_input(uint16_t* to_modify) void init_gpio(void) { - GPIO_InitTypeDef GPIO_InitStruct; + GPIO_InitTypeDef GPIO_InitStruct; // Enable SPI clocks RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); @@ -97,7 +97,7 @@ void init_gpio(void) { /*Enable or disable the AHB peripheral clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE); -// SPI PINSSS + // SPI PINSSS /*Configure GPIO pin : PB, MOSI, SCK */ GPIO_InitStruct.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_15; @@ -106,8 +106,8 @@ void init_gpio(void) { GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz; GPIO_Init(GPIOB, &GPIO_InitStruct); - GPIO_InitTypeDef GPIO_InitStruct2; -// MISO + GPIO_InitTypeDef GPIO_InitStruct2; + // MISO GPIO_InitStruct2.GPIO_Pin = GPIO_Pin_14; GPIO_InitStruct2.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStruct2.GPIO_PuPd = GPIO_PuPd_NOPULL; @@ -127,20 +127,20 @@ void init_gpio(void) { */ /*Enable or disable the AHB peripheral clock */ - RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); + //RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); - GPIO_InitTypeDef GPIO_InitStruct3; + //GPIO_InitTypeDef GPIO_InitStruct3; /*Configure GPIO pin : PA */ - GPIO_InitStruct3.GPIO_Pin = GPIO_Pin_11|GPIO_Pin_12; - GPIO_InitStruct3.GPIO_Mode = GPIO_Mode_AF; - GPIO_InitStruct3.GPIO_PuPd = GPIO_PuPd_NOPULL; - GPIO_InitStruct3.GPIO_Speed = GPIO_Speed_10MHz; - GPIO_InitStruct3.GPIO_OType = GPIO_OType_PP; - GPIO_Init(GPIOA, &GPIO_InitStruct3); - GPIO_SetBits(GPIOA, GPIO_Pin_12); // emz test - GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_USB); - GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_USB); + //GPIO_InitStruct3.GPIO_Pin = GPIO_Pin_11|GPIO_Pin_12; + //GPIO_InitStruct3.GPIO_Mode = GPIO_Mode_AF; + //GPIO_InitStruct3.GPIO_PuPd = GPIO_PuPd_NOPULL; + //GPIO_InitStruct3.GPIO_Speed = GPIO_Speed_10MHz; + //GPIO_InitStruct3.GPIO_OType = GPIO_OType_PP; + //GPIO_Init(GPIOA, &GPIO_InitStruct3); + //GPIO_SetBits(GPIOA, GPIO_Pin_12); // emz test + //GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_USB); + //GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_USB); } // vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/main.c b/main.c --- a/main.c +++ b/main.c @@ -343,6 +343,7 @@ uint8_t sw_right_last = 0; void save_settings() { +/* Minimal_EEPROM_Unlock(); // Try programming a word at an address divisible by 4 Minimal_EEPROM_ProgramWord(EEPROM_BASE_ADDR + EEPROM_ADDR_BOOTTOBREW, boottobrew); @@ -352,22 +353,25 @@ void save_settings() Minimal_EEPROM_ProgramWord(EEPROM_BASE_ADDR + EEPROM_ADDR_K_D, k_d); Minimal_EEPROM_ProgramWord(EEPROM_BASE_ADDR + EEPROM_ADDR_UNITS, temp_units); Minimal_EEPROM_Lock(); +*/ } void save_setpoints() { +/* Minimal_EEPROM_Unlock(); Minimal_EEPROM_ProgramWord(EEPROM_BASE_ADDR + EEPROM_ADDR_BREWTEMP, setpoint_brew); Minimal_EEPROM_ProgramWord(EEPROM_BASE_ADDR + EEPROM_ADDR_STEAMTEMP, setpoint_steam); Minimal_EEPROM_Lock(); +*/ } // TODO: Make a struct that has all settings in it. Pass by ref to this func in a library. void restore_settings() { - Minimal_EEPROM_Unlock(); +/* Minimal_EEPROM_Unlock(); while(Minimal_FLASH_GetStatus()==FLASH_BUSY); boottobrew = (*(__IO uint32_t*)(EEPROM_BASE_ADDR + EEPROM_ADDR_BOOTTOBREW)); @@ -391,7 +395,7 @@ void restore_settings() while(Minimal_FLASH_GetStatus()==FLASH_BUSY); temp_units = (*(__IO uint32_t*)(EEPROM_BASE_ADDR + EEPROM_ADDR_UNITS)); - Minimal_EEPROM_Lock(); + Minimal_EEPROM_Lock(); */ } int16_t last_temp = 21245; diff --git a/therm-cube.ioc b/therm-cube.ioc new file mode 100644 --- /dev/null +++ b/therm-cube.ioc @@ -0,0 +1,157 @@ +#MicroXplorer Configuration settings - do not modify +#Fri Nov 14 22:42:15 EST 2014 +File.Version=4 +KeepUserPlacement=false +Mcu.Family=STM32F0 +Mcu.IP0=NVIC +Mcu.IP1=RCC +Mcu.IP2=SPI1 +Mcu.IP3=SYS +Mcu.IP4=USART1 +Mcu.IP5=USB +Mcu.IP6=USB_DEVICE +Mcu.IPNb=7 +Mcu.Name=STM32F042K(4-6)Ux +Mcu.Package=UFQFPN32 +Mcu.Pin0=PA1 +Mcu.Pin1=PA2 +Mcu.Pin10=PA12 +Mcu.Pin11=PA13 +Mcu.Pin12=PA14 +Mcu.Pin13=PA15 +Mcu.Pin14=PB3 +Mcu.Pin15=PB4 +Mcu.Pin16=PB5 +Mcu.Pin17=PB6 +Mcu.Pin18=PB7 +Mcu.Pin19=PB8 +Mcu.Pin2=PA3 +Mcu.Pin20=VP_RCC_USB +Mcu.Pin21=VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS +Mcu.Pin3=PA4 +Mcu.Pin4=PA5 +Mcu.Pin5=PA6 +Mcu.Pin6=PA7 +Mcu.Pin7=PA9 +Mcu.Pin8=PA10 +Mcu.Pin9=PA11 +Mcu.PinsNb=22 +Mcu.UserName=STM32F042K6Ux +NVIC.SysTick_IRQn=true\:0\:0 +NVIC.USB_IRQn=true\:0\:0 +PA1.Locked=true +PA1.Signal=GPIO_Output +PA10.Locked=true +PA10.Mode=Asynchronous +PA10.Signal=USART1_RX +PA11.Locked=true +PA11.Mode=Device +PA11.Signal=USB_DM +PA12.Mode=Device +PA12.Signal=USB_DP +PA13.Locked=true +PA13.Mode=Serial-WireDebug +PA13.Signal=SYS_SWDIO +PA14.Mode=Serial-WireDebug +PA14.Signal=SYS_SWCLK +PA15.Locked=true +PA15.Signal=GPIO_Output +PA2.Locked=true +PA2.Signal=GPIO_Output +PA3.Locked=true +PA3.Signal=GPIO_Output +PA4.Locked=true +PA4.Signal=GPIO_Output +PA5.Locked=true +PA5.Mode=Full_Duplex_Master +PA5.Signal=SPI1_SCK +PA6.Locked=true +PA6.Mode=Full_Duplex_Master +PA6.Signal=SPI1_MISO +PA7.Locked=true +PA7.Mode=Full_Duplex_Master +PA7.Signal=SPI1_MOSI +PA9.Locked=true +PA9.Mode=Asynchronous +PA9.Signal=USART1_TX +PB3.Locked=true +PB3.Signal=GPIO_Input +PB4.Locked=true +PB4.Signal=GPIO_Input +PB5.Locked=true +PB5.Signal=GPIO_Input +PB6.Locked=true +PB6.Signal=GPIO_Input +PB7.Locked=true +PB7.Signal=GPIO_Input +PB8.Locked=true +PB8.Signal=GPIO_Output +PCC.Family=STM32F0 +PCC.MCU=STM32F042K(4-6)Ux +PCC.MXVersion=4.4.0 +PCC.PartNumber=STM32F042K6Ux +PCC.Seq0=0 +PCC.SubFamily=STM32F0x2 +PCC.Temperature=25 +PCC.Vdd=3.6 +RCC.CECEnable-ClockTree=false +RCC.EnableHSE-ClockTree=false +RCC.EnableHSERTCDevisor-ClockTree=false +RCC.EnableLSE-ClockTree=false +RCC.EnableLSERTC-ClockTree=false +RCC.EnableMCOMultDivisor-ClockTree=false +RCC.FLatency-AdvancedSettings=FLASH_LATENCY_0 +RCC.FamilyName=M +RCC.HSEState-ClockTree=RCC_HSE_OFF +RCC.HSI14State-ClockTree=RCC_HSI14_OFF +RCC.HSI48State-ClockTree=RCC_HSI48_ON +RCC.HSIState-ClockTree=RCC_HSI_ON +RCC.I2C1Enable-ClockTree=false +RCC.IPParameters=OscillatorTypeHSE-ClockTree,RTCEnable-ClockTree,EnableLSE-ClockTree,CECEnable-ClockTree,ReloadValue-AdvancedSettings,PLLCLKFreq_Value,FamilyName,PREFETCH_ENABLE-AdvancedSettings,OscillatorTypeHSI48-ClockTree,USBEnable-ClockTree,HSI14State-ClockTree,PLLMCOFreq_Value,IWDGEnable-ClockTree,HSI48State-ClockTree,FLatency-AdvancedSettings,EnableLSERTC-ClockTree,USART2Enable-ClockTree,Source-AdvancedSettings,VCOOutput2Freq_Value,MCOEnable-ClockTree,OscillatorTypeHSI-ClockTree,EnableMCOMultDivisor-ClockTree,I2C1Enable-ClockTree,HSIState-ClockTree,LSIState-ClockTree,PLLState-ClockTree,RCC_PERIPHCLK_USART1Var-ClockTree,USART1Enable-ClockTree,HSEState-ClockTree,EnableHSE-ClockTree,EnableHSERTCDevisor-ClockTree,OscillatorTypeLSI-ClockTree +RCC.IWDGEnable-ClockTree=false +RCC.LSIState-ClockTree=RCC_LSI_OFF +RCC.MCOEnable-ClockTree=false +RCC.OscillatorTypeHSE-ClockTree= +RCC.OscillatorTypeHSI-ClockTree=RCC_OSCILLATORTYPE_HSI +RCC.OscillatorTypeHSI48-ClockTree=RCC_OSCILLATORTYPE_HSI48 +RCC.OscillatorTypeLSI-ClockTree= +RCC.PLLCLKFreq_Value=16000000 +RCC.PLLMCOFreq_Value=16000000 +RCC.PLLState-ClockTree=RCC_PLL_OFF +RCC.PREFETCH_ENABLE-AdvancedSettings=0 +RCC.RCC_PERIPHCLK_USART1Var-ClockTree=RCC_PERIPHCLK_USART1 +RCC.RTCEnable-ClockTree=false +RCC.ReloadValue-AdvancedSettings=__HAL_RCC_CRS_CALCULATE_RELOADVALUE(48000000, +RCC.Source-AdvancedSettings=RCC_CRS_SYNC_SOURCE_USB +RCC.USART1Enable-ClockTree=true +RCC.USART2Enable-ClockTree=false +RCC.USBEnable-ClockTree=true +RCC.VCOOutput2Freq_Value=8000000 +SPI1.DataSize-Full_Duplex_Master=SPI_DATASIZE_8BIT +SPI1.Direction-Full_Duplex_Master=SPI_DIRECTION_2LINES +SPI1.IPParameters=Direction-Full_Duplex_Master,VirtualType-Full_Duplex_Master,TIMode-Full_Duplex_Master,Mode-Full_Duplex_Master,DataSize-Full_Duplex_Master,NSS-Full_Duplex_Master +SPI1.Mode-Full_Duplex_Master=SPI_MODE_MASTER +SPI1.NSS-Full_Duplex_Master=SPI_NSS_SOFT +SPI1.TIMode-Full_Duplex_Master=SPI_TIMODE_DISABLED +SPI1.VirtualType-Full_Duplex_Master=VM_MASTER +USART1.BaudRate=115200 +USART1.HwFlowCtl-Asynchronous=UART_HWCONTROL_NONE +USART1.IPParameters=VirtualMode-Asynchronous,BaudRate,HwFlowCtl-Asynchronous,WordLength-Asynchronous +USART1.VirtualMode-Asynchronous=VM_ASYNC +USART1.WordLength-Asynchronous=UART_WORDLENGTH_7B +USB.IPParameters=phy_itface-Device,speed-Device +USB.phy_itface-Device=PCD_PHY_EMBEDDED +USB.speed-Device=PCD_SPEED_FULL +USB_DEVICE.CLASS_NAME-CDC_FS=CDC +USB_DEVICE.IPParameters=CLASS_NAME-CDC_FS,VirtualModeFS,VirtualMode,USBD_HandleTypeDef,hUsbDevice-CDC_FS,USBD_HandleTypeDef-CDC_FS,VirtualModeFS-CDC_FS,VirtualMode-CDC_FS +USB_DEVICE.USBD_HandleTypeDef=hUsbDeviceFS +USB_DEVICE.USBD_HandleTypeDef-CDC_FS=hUsbDeviceFS +USB_DEVICE.VirtualMode=Cdc +USB_DEVICE.VirtualMode-CDC_FS=Cdc +USB_DEVICE.VirtualModeFS=Cdc_FS +USB_DEVICE.VirtualModeFS-CDC_FS=Cdc_FS +USB_DEVICE.hUsbDevice-CDC_FS=hDeviceDuSmolt +VP_RCC_USB.Mode=CRS SYNC Source USB +VP_RCC_USB.Signal=RCC_USB +VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Mode=CDC_FS +VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Signal=USB_DEVICE_VS_USB_DEVICE_CDC_FS