Skip to content

Commit

Permalink
Add function to calculate minimum bits required to represent code length
Browse files Browse the repository at this point in the history
  • Loading branch information
zsoerenm committed Feb 26, 2020
1 parent 2cc8b5e commit 9af2348
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GNSSSignals"
uuid = "52c80523-2a4e-5c38-8979-05588f836870"
authors = ["Soeren Zorn <[email protected]>"]
version = "0.12.1"
version = "0.12.2"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Expand Down
3 changes: 2 additions & 1 deletion src/GNSSSignals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ module GNSSSignals
get_quadrant_size_power,
get_carrier_amplitude_power,
fpcarrier_phases!,
fpcarrier!
fpcarrier!,
min_bits_for_code_length

abstract type AbstractGNSSSystem end

Expand Down
2 changes: 2 additions & 0 deletions src/carrier.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function fpcarrier_phases!(
fixed_point_phase = fixed_point_phase + delta
phases[i] = T(fixed_point_phase >> fixed_point)
end
phases
end

"""
Expand Down Expand Up @@ -179,4 +180,5 @@ function fpcarrier!(
num_samples = num_samples,
bits = bits
)
carrier
end
14 changes: 14 additions & 0 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,17 @@ julia> get_code_unsafe(GPSL1, 10.3, 1)
@inline function get_code_center_frequency_ratio(::Type{T}) where T <: AbstractGNSSSystem
get_code_frequency(T) / get_center_frequency(T)
end

"""
$(SIGNATURES)
Minimum bits that are needed to represent the code length
"""
function min_bits_for_code_length(::Type{S}) where S <: AbstractGNSSSystem
for i = 1:32
if get_code_length(S) * get_secondary_code_length(S) <= 1 << i
return i
end
end
return 0
end

0 comments on commit 9af2348

Please sign in to comment.