Files
        @ 41c563eb0a68
    
        
              Branch filter: 
        
    Location: therm/gpio.c - annotation
        
            
            41c563eb0a68
            4.1 KiB
            text/plain
        
        
    
    Remove old usb cruft
    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147  | 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 08c52ee196d1 49b0586d1fdf 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 49b0586d1fdf 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 49b0586d1fdf 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 49b0586d1fdf 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 49b0586d1fdf 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 49b0586d1fdf 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 49b0586d1fdf 8f02a0213d08 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 49b0586d1fdf 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 de0b4c3c6dc2 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 8f02a0213d08 49b0586d1fdf 49b0586d1fdf 49b0586d1fdf  | #include "gpio.h"
#include "config.h"
extern volatile uint32_t ticks;
// Increase on each press, and increase at a fast rate after duration elapsed of continuously holding down... somehow...
uint32_t change_time_reset = 0;
void user_input(uint16_t* to_modify)
{
    if(CHANGE_ELAPSED) {
        if(!GPIO_ReadInputDataBit(SW_UP) ) {
            CHANGE_RESET;
            (*to_modify)++;
        }
        else if(!GPIO_ReadInputDataBit(SW_DOWN) && (*to_modify) > 0) {
            CHANGE_RESET;
            (*to_modify)--;
        }
    }
}
void init_gpio(void) {
  GPIO_InitTypeDef GPIO_InitStruct;
    /* GPIO Ports Clock Enable */
  __GPIOF_CLK_ENABLE();
  __GPIOA_CLK_ENABLE();
  __GPIOB_CLK_ENABLE();
   
  //////////////////
  // PORT F       //
  //////////////////  
  
  // PORTF OUTPUT
  // Configure GPIO pin : PF0
  GPIO_InitStruct.Pin = GPIO_PIN_0;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
  // PORTF UNUSED
  // Configure GPIO pin : PF1
  GPIO_InitStruct.Pin = GPIO_PIN_1;
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
  
  //////////////////
  // PORT A       //
  //////////////////
  
  // PORT A OUTPUT
  // Configure GPIO pins : PA1 PA2 PA3 PA4
  GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  
  // PORTA INPUT
  // Configure GPIO pin : PA15 
  GPIO_InitStruct.Pin = GPIO_PIN_15;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  // PORTA UNUSED
  // Configure GPIO pins : PA0 PA8
  GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_8;
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  
  // USART1 [PORTA]
  // Configure GPIO pins : PA9 PA10
  GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10;
  GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
  GPIO_InitStruct.Alternate = GPIO_AF1_USART1;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  // SPI1 [PORTA]
  // Configure GPIO pin : PA, MOSI, SCK 
  GPIO_InitStruct.GPIO_Pin = GPIO_PIN_7|GPIO_PIN_5;
  GPIO_InitStruct.GPIO_Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.GPIO_PuPd = GPIO_NOPULL;
  GPIO_InitStruct.GPIO_Speed = GPIO_SPEED_HIGH;
  GPIO_InitStruct.Alternate = GPIO_AF1_SPI1;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  
  // Configure GPIO pin: PA, MISO
  GPIO_InitStruct.GPIO_Pin = GPIO_PIN_6;
  GPIO_InitStruct.GPIO_Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.GPIO_PuPd = GPIO_NOPULL;
  GPIO_InitStruct.GPIO_Speed = GPIO_SPEED_HIGH;
  GPIO_InitStruct.Alternate = GPIO_AF1_SPI1;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  // USB [PORTA]
  /** USB GPIO Configuration  
  PA11   ------> USB_DM
  PA12   ------> USB_DP
  */  
  // Configure GPIO pin : PA, D+, D-
  GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11|GPIO_Pin_12;
  GPIO_InitStruct.GPIO_Mode = GPIO_MODE_AF_PP;
  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
  GPIO_InitStruct.GPIO_Speed = GPIO_Speed_10MHz;
  GPIO_InitStruct.Alternate = GPIO_AF1_USB;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
  
  //////////////////
  // PORT B       //
  //////////////////
  
  // PORT B UNUSED
  // Configure GPIO pins : PB0 PB1 PB8 
  GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_8;
  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
  // PORT B INPUT
  // Configure GPIO pins : PB3 PB4 PB5 PB6 PB7
  GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6 
                          |GPIO_PIN_7;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);  
  
  
  // Enable DMA clocks (Is AHB even the right thing???)
  //RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); // EMZ TODO get the right ones
}
// vim:softtabstop=4 shiftwidth=4 expandtab 
 |