-
Notifications
You must be signed in to change notification settings - Fork 4
Cambios spi #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Cambios spi #6
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| +0 −27 | inc/BMI088Middleware.h | |
| +0 −112 | inc/BMI088driver.h | |
| +0 −180 | inc/BMI088reg.h | |
| +0 −179 | inc/OLED.h | |
| +0 −41 | inc/ist8310driver.h | |
| +0 −38 | inc/ist8310driver_middleware.h | |
| +0 −373 | inc/oledfont.h | |
| +0 −56 | src/BMI088Middleware.c | |
| +0 −557 | src/BMI088driver.c | |
| +0 −457 | src/OLED.c | |
| +0 −108 | src/ist8310driver.c | |
| +0 −72 | src/ist8310driver_middleware.c |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #include "main.h" | ||
| #include "robotconfig.h" | ||
|
|
||
|
|
||
| typedef struct { | ||
| SPI_HandleTypeDef* spiHandle; | ||
| GPIO_TypeDef* csPort; | ||
| uint16_t csPin; //esto directamente nose, pero venia en un ejemplo que vi | ||
| } SPI_Config; | ||
|
|
||
| SPI_Config SPI1_Config = { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Igual, no hay necesidad de inicializarla |
||
| .spiHandle = &hspi1, | ||
| .csPort = SPI1_CS_PORT, | ||
| .csPin = SPI1_CS_PIN | ||
| }; | ||
|
|
||
| // Inicia SPI | ||
| void SPI_Init(SPI_Config* config) { | ||
| HAL_GPIO_WritePin(config->csPort, config->csPin, GPIO_PIN_SET); | ||
| } | ||
|
|
||
| // envia y recibe | ||
| uint8_t SPI_Transfer(SPI_Config* config, uint8_t data) { | ||
| uint8_t receivedData; | ||
| HAL_GPIO_WritePin(config->csPort, config->csPin, GPIO_PIN_RESET); | ||
| HAL_SPI_TransmitReceive(config->spiHandle, &data, &receivedData, 1, HAL_MAX_DELAY); | ||
| HAL_GPIO_WritePin(config->csPort, config->csPin, GPIO_PIN_SET); | ||
| return receivedData; | ||
| } | ||
|
|
||
| int main(void) { | ||
| HAL_Init(); | ||
| tim(); //voy a creer que es lo del relog | ||
| MX_GPIO_Init(); | ||
| MX_SPI1_Init(); | ||
|
|
||
|
|
||
| SPI_Init(&SPI1_Config); | ||
|
|
||
| while (1) { | ||
|
|
||
| uint8_t command = 0x01; | ||
| uint8_t response = SPI_Transfer(&SPI1_Config, command); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Increíble, jaja |
||
|
|
||
| HAL_Delay(1000); // awanta 1 segundo | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No es tan necesario. porque en teoría ya está definido en el robot config