/** * @brief BSP of the 4 digits 7 Segment Display shield for Arduino Nano - Gravitech. Display the value if value belong to [0-9999] * @param Value A number between 0 and 9999 will be displayed on the screen. * DIGIT4_SEG7_RESET will reset the screen (any value above 9999 will reset the screen also) * @retval HAL_StatusTypeDef */ HAL_StatusTypeDef BSP_DIGIT4_SEG7_Display(uint32_t Value) { const uint8_t lookup[10] = {0x3F,0x06,0x5B,0x4F,0x66, 0x6D,0x7D,0x07,0x7F,0x6F}; uint32_t thousands, hundreds, tens, base; HAL_StatusTypeDef status = HAL_ERROR; uint8_t d1d2d3d4[4]; if (Value < 10000) { thousands = Value / 1000; hundreds = (Value - (thousands * 1000)) / 100; tens = (Value - ((thousands * 1000) + (hundreds * 100))) / 10; base = Value - ((thousands * 1000) + (hundreds * 100) + (tens * 10)); d1d2d3d4[3] = lookup[thousands]; d1d2d3d4[2] = lookup[hundreds]; d1d2d3d4[1] = lookup[tens]; d1d2d3d4[0] = lookup[base]; } else { d1d2d3d4[3] = 0; d1d2d3d4[2] = 0; d1d2d3d4[1] = 0; d1d2d3d4[0] = 0; } /* Send the four digits to the SAA1064 component */ status = I2C1_WriteBuffer(0x70, 1, 1, d1d2d3d4, sizeof(d1d2d3d4)); return status; }
/** * @brief BSP of the 4 digits 7 Segment Display shield for Arduino Nano - Gravitech. init * @retval HAL_StatusTypeDef */ HAL_StatusTypeDef BSP_DIGIT4_SEG7_Init(void) { uint8_t control[1] = {0x47}; /* Init I2C */ I2C1_Init(); /* Configure the SAA1064 component */ return I2C1_WriteBuffer(0x70, 0, 1, control, sizeof(control)); }
/** * @brief Writes one byte to the TSENSOR. * @param DevAddress: Target device address * @param pBuffer: Pointer to data buffer * @param WriteAddr: TSENSOR's internal address to write to. * @param Length: Number of data to write * @retval None */ void TSENSOR_IO_Write(uint16_t DevAddress, uint8_t* pBuffer, uint8_t WriteAddr, uint16_t Length) { I2C1_WriteBuffer(DevAddress, WriteAddr, I2C_MEMADD_SIZE_8BIT, pBuffer, Length); }
/** * @brief Write data to I2C EEPROM driver * @param DevAddress: Target device address * @param MemAddress: Internal memory address * @param pBuffer: Pointer to data buffer * @param BufferSize: Amount of data to be sent * @retval HAL status */ HAL_StatusTypeDef EEPROM_IO_WriteData(uint16_t DevAddress, uint16_t MemAddress, uint8_t* pBuffer, uint32_t BufferSize) { return (I2C1_WriteBuffer(DevAddress, MemAddress, I2C_MEMADD_SIZE_16BIT, pBuffer, BufferSize)); }